Hi,
I was 'playing' with some physics and stumbled about an
Assertion failed error when I tried to start the app.
I just used the sample code 'Physics->Bridge' and removed the creation code of the bridge and the boxes.
This is the error message:
Mirosoft Visual C++ Runtime Library
Assertion failed!
bla bla... b2Joint.cpp - Line 173
Expression: def->bodyA != def->bodyB |
This is my code
--[[
This code is MIT licensed, see <a href="http://www.opensource.org/licenses/mit-license.php" rel="nofollow">http://www.opensource.org/licenses/mit-license.php</a>
(C) 2010 - 2011 Gideros Mobile
]]
require "box2d"
b2.setScale(10)
-- this table holds the dynamic bodies and their sprites
local actors = {}
-- create world
local world = b2.World.new(0, 9.8)
-- create ground body
local ground = world:createBody({})
-- create an edge shape, and attach it to the ground body as a fixture
local shape = b2.EdgeShape.new(0, 480, 320, 480)
ground:createFixture({shape = shape, density = 0})
-- this box shape will be used while creating the bridge elements
local shape = b2.PolygonShape.new()
shape:setAsBox(11, 2)
-- and our fixture definition
local fixtureDef = {shape = shape, density = 20, friction = 0.2}
-- start to create the bridge
local prevBody = ground
-- attach last bridge element to the ground body
local jointDef = b2.createRevoluteJointDef(prevBody, ground, 300, 250)
world:createJoint(jointDef)
-- this box shape will be used while creating boxes falling down
local shape = b2.PolygonShape.new()
shape:setAsBox(10, 10)
local fixtureDef = {shape = shape, density = 2, restitution = 0.7}
-- step the world and then update the position and rotation of sprites
local function onEnterFrame()
world:step(1/60, 8, 3)
for body,sprite in pairs(actors) do
sprite:setPosition(body:getPosition())
sprite:setRotation(body:getAngle() * 180 / math.pi)
end
end
stage:addEventListener(Event.ENTER_FRAME, onEnterFrame) |
I know that my code makes no sense but it should not cause Gideros to crash
.
Comments
-- attach last bridge element to the ground body
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive
I wanted to modify the code and try somes things. I removed the parts I wanted to replace and just pressed run to test if the code still 'compiles' and then it crashed .
I just thought that it is not a wanted behaviour that gideros crashes like this, so I posted the error here.
Good catch
Website: http://www.castlegateinteractive.com
https://play.google.com/store/apps/developer?id=Castlegate+Interactive