Hi,
I have an “enterframe” listener to constantly set the speed of a falling display object. On collision this display object is destroyed. When the object is destroyed my call to “setLinearVelocity” returns nil and I get an error dispite having checks to see if the object exists before I call “setLinearVelocity”. Below is my code:
function setspeed(e)
if (bangflag == false) then
if (b ~= nil) then
vx, vy = b:getLinearVelocity()
b:setLinearVelocity( vx, 110 + (level \* 10) )
end
end
end
Runtime:addEventListener("enterFrame", setspeed);
“bangflag” is a flag I set whenever a collision is detected so this should not fire during a collision. “b” is a var used to hold display objects and I check to make sure it is not nil before calling “setLinearVelocity”. Please note removing the event listener is not an option as I need it for other display objects. [import]uid: 31694 topic_id: 24155 reply_id: 324155[/import]