Your restart scene needs to be a scene. In your scene:create() put in a background, a message saying “Game over” or “Try again?” and give them a button to select to go back.
I suspect you’re trying to work around restarting a scene by deleting the old scene so it will reset when it restarts. There are two ways to do this. The first is to use a cut scene, which is what you’re trying to do. This allows you to blow away the game scene and which will start it back to the original. But the idea behind a cut scene is, well that it’s a scene. This is why I say to make the scene something that the user has to interact with. This gives you time to remove the level scene in the composer:show()'s did phase. This allows your cut scene to be created and shown while simultaneously removing the level scene. The lines:
composer.removeScene(“lvl1”)
composer.removeHidden()
composer.gotoScene(“lvl1”)
need to go inside scene:show():
function scene:show( event ) if event.phase == "did" then composer.removeScene("lvl1") composer.removeHidden() composer.gotoScene("lvl1") end end
If you do not want a visible cut-scene, then your choice is to manually reset everything that you need to reset in your lvl1 scene. This should be done in the scene’s composer:show() in the “will” phase.
But I highly recommend using the visual cut scene method.
Rob