I don’t believe this is a bug. It’s just not how you want it to work. This same issue was present in Storyboard which lead me to do the video tutorial on Reloading Storyboard:
http://coronalabs.com/blog/2013/08/20/tutorial-reloading-storyboard-scenes/
The gist of it is when a scene is on the screen, it cannot be destroyed and re-created… plain and simple. If it did, there would be nothing to show.
Reloading a scene does not generally require the scene to be recreated. It simply needs reset. Keeping in mind any code run (initializing variables, starting physics, etc.) that is in the scene’s main chunk only executes when the scene is “required” for the first time, so:
local livesRemaining = 10
at the top of your module won’t reset unless you’re able to call composer.removeScene() and you shouldn’t try and remove the scene you’re in. The solution? Use a cut scene and remove your game scene while the cut scene is showing. This is a very common design pattern among games… pacman, angry birds, candy crush, etc. If you don’t mind the flash, you could have an all black cut scene that simply removes the game and goes back to it as quickly as possible.
However the **right** thing to do is to use your scene:show()'s “will” phase and reposition your objects that may have moved back to their starting location. A pain, yes, but if you’re doing:
player = display.newImageRect(“player.png”, 100, 100(
player.x = 100
player.y = 100
you are already writing the position code, just move those last two lines to the “will” phase and don’t worry about positioning them in scene:create().
For the last round of issues, you cannot call gotoScene() in a scene’s scene:hide() event because gotoScene is what triggers the scene:hide(). If you plan to use the sceneRemove() technique to reset a scene, then it has to happen before calling gotoScene() because it’s too late to remove the scene that gotoScene() is trying to go to.
I’m developing a multi-level game right now using the composer API. I’m using the cut scene method to show the level score, number of stars, etc. and I can load my game scene over and over and over. Create a scene that says “Try again”, show that message for a couple of seconds while you’re removing the game scene and go back to it. Even better give your user a choice to try again or quit (goto your menu, etc.) from that cut scene.
Rob