Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Assertion failed error — Gideros Forum

Assertion failed error

gyrospgyrosp Member
edited November 2012 in Bugs and issues
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

  • ScouserScouser Guru
    edited November 2012
    Interesting, this is just part of the bridge example with the bridge part missing. The problem here is you are trying to create a joint from a body (ground) to itself. The bridge code
    for i=0,13 do
    	local bodyDef = {type = b2.DYNAMIC_BODY, position = {x = 30 + i * 20, y = 250}}
    	local body = world:createBody(bodyDef)
    	body:createFixture(fixtureDef)
     
    	local bitmap = Bitmap.new(Texture.new("rect.png", true))
    	bitmap:setAnchorPoint(0.5, 0.5)
    	stage:addChild(bitmap)
     
    	actors[body] = bitmap
     
    	-- attach each pair of bridge elements with revolute joint
    	local jointDef = b2.createRevoluteJointDef(prevBody, body, 20 + i * 20, 250)
    	world:createJoint(jointDef)
     
    	prevBody = body
    end
    needs to be inserted before the line
    -- attach last bridge element to the ground body
    As far as I know, a joint must be attached to 2 separate bodies.
  • Yes, I know :D. As I mentioned the code makes no sense.
    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.
  • Ah, now I understand. This is just a simple oversight and can probably be fixed quite easily by checking the bodyA & bodyB are not the same when creating joints. I have just checked this on my Android phone and it didn't report any errors / problems so it would appear to only be the windows player.

    Good catch :)
Sign In or Register to comment.