Composer.removeScene() not working

Hey guys I have a question about removing the scene so the game just forgets about it and then when you go back to it it is a fresh new scene. My code is set up so when the enemy “zombie” collides with your boat it will go to the lose scene and I also have it print when the zombies is colliding with your boat. And when I change scenes it is still printing like it is all still their

Thanks ,Tyler Jacobson

We are going to need to see some code.  The code where you are changing scenes  and the code where you’re trying to remove the scene.

Rob

Ok Rob I will post the code

local boat = display.newRect(0,99,30,400) physics.addBody(boat,"static") local function die(event) print("you lose") composer.removeScene("level1") composer.gotoScene("lose") end boat:addEventListener("collision",die)

Is this code part of level1.lua?  If so you cannot remove the scene you are currently in.  Either do a:

composer.removeScene(“level1”) before you call composer.gotoScene(“level1”) or in “lose.lua”, put composer.removeScene(“level1”) in the scene:show() during the “did” phase.

Rob

We are going to need to see some code.  The code where you are changing scenes  and the code where you’re trying to remove the scene.

Rob

Ok Rob I will post the code

local boat = display.newRect(0,99,30,400) physics.addBody(boat,"static") local function die(event) print("you lose") composer.removeScene("level1") composer.gotoScene("lose") end boat:addEventListener("collision",die)

Is this code part of level1.lua?  If so you cannot remove the scene you are currently in.  Either do a:

composer.removeScene(“level1”) before you call composer.gotoScene(“level1”) or in “lose.lua”, put composer.removeScene(“level1”) in the scene:show() during the “did” phase.

Rob