In my game I have collisions in which I need to break objects and make them disappear. I am using the Director Class. Here is a stripped down sample of my code.
[lua]local function onPostCollision( event )
if event.force > 2 then
event.object1:removeSelf()
–I have also tried if event.object1 then event.object1:removeSelf end
end
end
Runtime:addEventListener(“postCollision”, onPostCollision)
–later on when changing scene
Runtime:removeEventListener(“postCollision”, onPostCollision)[/lua]
It works the first time, but when the stage is reloaded or revisited via Director, I get this error:
ERROR: Attempt to remove an object that has already been removed from the stage or whose parent/ancestor group has already been removed.
How do I fix this? Thanks [import]uid: 54716 topic_id: 15159 reply_id: 315159[/import]
