Sometimes throughout my game, I get an error message in the terminal which is about removing objects. The error message only comes up like once or twice throughout the game but sometimes the object freezes without being removed. This is the only thing that is holding me back and I can’t find out what I’m doing wrong. Here is the error message:
"Runtime error
ERROR: Attempt to remove an object that’s already been removed from the stage or whose parent/ancestor group has already been removed.
stack traceback:
C: in function ‘removeSelf’
?: in function ‘remove’
This error message only comes up whenever I hit a bomb with a bullet. I want the bomb to be completely removed whenever it’s hit with a bullet so I can show an animation there. So whenever a bullet hits a bomb, the bomb is removed like this:
[lua]if object1.name == “bomb” and object2.name == “bullet” then
local function turnOffBody()
object1.isBodyActive = false
–Destroy the bullet and bomb when it collides with the bomb
display.remove(object1)
display.remove(object2)
end
timer.performWithDelay(1, turnOffBody)
end
end
return true
end [import]uid: 69494 topic_id: 31588 reply_id: 331588[/import]


[import]uid: 69494 topic_id: 31588 reply_id: 126472[/import]