Error in moving back to a previous scene using the director class

Hi,
i’m building a game that has three scenes ; Welcome, Menu, and the game screen
there’s an object ‘a stone’ that is supposed to be used 3 times to hit something … and after every hit i use the ’ removeSelf() ’ function to remove this stone and then generate the next one by calling this function with a nextStone button … :
local function resetStone()
stone_eg = display.newImage(“Objects/eagle_stone.png”)
localGroup:insert(stone_eg)
stone_eg.x=eagle.x-5
stone_eg.y=eagle.y+35
physics.addBody(stone_eg,“kinematic”, {density=10.0, friction=0.1, bounce=0, radius=10})
stone_eg.type=“stone”
end

after throwing it three times … a ‘game over’ button is shown up … and this button action is to go back to the Menu screen
the problem is when i press play again to play one more time … after the first stone hit, an error occurred

ERROR: Attempt to remove an object that’s already been removed from the stage or whose parent/ancestor group has already been removed.

in this line: stone:removeSelf()
any thoughts !!??
[import]uid: 96659 topic_id: 17993 reply_id: 317993[/import]

I have this same issue.

ERROR: Attempt to remove an object that’s already been removed from the stage or whose parent/ancestor group has already been removed.

Have you found a resolution? [import]uid: 80890 topic_id: 17993 reply_id: 68795[/import]

Are you removing your localGroup in the clean function? [import]uid: 19626 topic_id: 17993 reply_id: 68796[/import]

i don’t have a clean function yet, in order to avoid something like this !! [import]uid: 96659 topic_id: 17993 reply_id: 68900[/import]

The reason I asked is I was putting the localGroup:removeSelf() in my clean functions and was getting a similar error. Took it out and the error went away, but if you don’t have a clean function… well in the infamous words of Emily Latilla (a Gilda Radner character from the original Saturday Night Live) “Never mind…”

[import]uid: 19626 topic_id: 17993 reply_id: 68919[/import]

I’ve figured out why mine is happening the Runtime:addEventListener( “collision”, onGlobalCollision ) is firing twice for the began process. Works fine the first time you play the level but the second time it will call it twice for the began to fire. I remove the event listener when the level is done so I’m not sure why it happens.
[import]uid: 80890 topic_id: 17993 reply_id: 68920[/import]

@weberkeith : … you’re right … i do the same ate mine now … and it works well

I removed the event Listener of the collision function at the action of the game over button
… and no errors occur when i play again and hit rocks … so the first eventListener is over with the first time played and the second one is working normal like the first one

thanks Buddy, :wink: [import]uid: 96659 topic_id: 17993 reply_id: 68926[/import]