hi,
please can you tell me why i get this simulator crash error? it seems to run file for a while, but in a specific instance I cannot determine the reason for it crashes. I can only assume that because removeSelf is not instant then 2 things are trying to act on it “at once”
thanks
j
Assertion failed: (0 <= proxyId && proxyId < m_nodeCapacity), function GetFatAABB, file …/…/external/Box2D_v2.1.2/Box2D/Box2D/Collision/b2DynamicTree.h, line 141.
/Applications/Corona Game Edition 2010.109/Corona Terminal: line 9: 1617 Abort trap “$path/Corona Simulator.app/Contents/MacOS/Corona Simulator” $*
[lua]local physics = require(“physics”)
local rnd = math.random
physics.start()
local line = display.newRect(0,300,170,20)
line:setFillColor(255,0,0)
line.is=“line”
physics.addBody(line, “static”, {density=1})
local function removeBall(obj,reason)
Runtime:removeEventListener(“enterFrame”, obj)
print(obj, reason)
if(obj~=nil) then
if(obj.transition~=nil) then transition.cancel(obj.transition) end
– *** occasionally crashes *** —
if(obj.removeSelf) then obj:removeSelf() end
end
return true
end
local function lineUp(event)
transition.to(line, {time=50, y=310})
end
local function globalCollision(event)
local obj1 = event.object1
local obj2 = event.object2
– if round ball hits line
if(obj2.is==“round” and obj1.is==“line”) then
transition.to(obj1, {time=100, y=obj1.y+10, onComplete=lineUp})
obj2.isBodyActive=false
obj2.transition = transition.to(obj2, {time=500, alpha=0, onComplete=function()removeBall(obj2,“hit line”)end})
return true
end
return true
end
local function newBall()
local ball
local radius = rnd(50)+5
local pick = math.floor(rnd(2))
if(pick==1) then
ball = display.newCircle(rnd(280)+20, 20, radius)
physics.addBody(ball, “dynamic”, {density=0.5, bounce=0.5,radius=radius})
ball.is=“round”
elseif(pick==2) then
ball = display.newRect(rnd(280)+20, 20,4,4)
physics.addBody(ball, “dynamic”, {density=1, bounce=0.1})
ball.is=“square”
end
ball:setFillColor(0,255,0)
ball.isBullet=true
– to be safe remove balls if they fall off the lower part of the screen
– otherwise they will continue falling forever
ball.enterFrame=function(self, event)
local ypos = self.y
if(ypos > 300) then self:setFillColor(255,0,0) end
if(ypos > 400) then removeBall(self,“y > 400”) end
end
Runtime:addEventListener(“enterFrame”, ball)
end
Runtime:addEventListener(“collision”, globalCollision)
timer.performWithDelay(100,newBall,-1)[/lua] [import]uid: 6645 topic_id: 4106 reply_id: 304106[/import]
