is it possible for corona to know which scene was previously shown?

if i have a game, menu.lua, level1.lua,level2.lua and i create a scene for when the user makes a mistake called redo.lua, this shown will tell the user to try again, then the user will press a button to return to the previous scene.

is this possible or do i have to create a specific redo.lua for each level(redo1.lua,redo2.lua)

thx for your help

It’s a lot easier to reload the scene you want them to redo, because that scene file already has all the logic in it. The logic would be to make sure all of your scene elements are cleaned up in the hide.did phase and created from scratch in the show.will phase.

On the other hand, if you have defined all the scene data in a file which can be loaded by a scene module then you don’t really need a level1.lua, level2.lua, etc. because all scenes can be loaded by the same module.

The key thing with both approaches is to make sure you clean up everything you create.

local previousScene = composer.getSceneName( "previous" )

See: https://docs.coronalabs.com/api/library/composer/getSceneName.html

Rob

It’s a lot easier to reload the scene you want them to redo, because that scene file already has all the logic in it. The logic would be to make sure all of your scene elements are cleaned up in the hide.did phase and created from scratch in the show.will phase.

On the other hand, if you have defined all the scene data in a file which can be loaded by a scene module then you don’t really need a level1.lua, level2.lua, etc. because all scenes can be loaded by the same module.

The key thing with both approaches is to make sure you clean up everything you create.

local previousScene = composer.getSceneName( "previous" )

See: https://docs.coronalabs.com/api/library/composer/getSceneName.html

Rob