Hey Eric,
I’m having a similar issue to amigoni. I just want to create a circle and then a physics body. When the circle get’s to a certain point, I want to remove it from stage/memory.
But when I run the code below, I get a runtime error, “attempt to compare nil with number”.
Do you have any idea what’s going on?
[lua]local myCircle = display.newCircle(100, 100, 30)
myCircle:setFillColor(128, 128, 128)
myCircle.x = 100; myCircle.y = 100
local physics = require(“physics”)
physics.start()
physics.addBody(myCircle, {density=2.7, friction=0.5, bounce=0.3})
myCircle:applyForce( 250, -4000, myCircle.x, myCircle.y )
local function removeCircle(event)
if(myCircle.y < 300) then
myCircle:removeSelf()
end
end
Runtime:addEventListener(“enterFrame”, removeCircle)[/lua] [import]uid: 29663 topic_id: 1775 reply_id: 19657[/import]