Scene Transition Bug

Hope all is well despite in this pandemic.

Guys i have a problem in transitioning my scene. In my game when the game runs and on the screen there’s these two buttons appeared on the bottom part of the screen namely the “Play Again” and “Menu” buttons.

First problem: The problem i have encountered is when the game is running and you pressed Play Again button it won’t reset to the very start of the game unless if it’s game over because it will go back from the start if Play Again button is pressed.

Second Problem: My Menu button did not work properly sometimes menu scene will display and if it display some objects that are part of the game stay on the screen together with the menu scene. And sometimes it will not function at all.

Your tips and support would be much appreciated.

Please just bear with me i am just a newbie here. Thank you, stay safe and stay at home.

Without seeing any code, these are just guesses.

My first guess is that your function(s) are out of scope. If you’ve placed the functions inside scene:create() then they will only be accessible from there. So, they would be accessible if you launch your game from scene:create(), but if you leave the scene and come back, then the scene will still exist, so it won’t get recreated and so the scene:create() function doesn’t get called.

My second guess is that you don’t insert all of your display objects to display groups and/or insert those display groups or display objects to the scene group. If you are using Composer to manage your scenes, then you must insert every object or group to the scene group, otherwise Composer won’t manage them.

As to why your “Play Again” button doesn’t work, it may be the same issue that it only reloads the scene, so it doesn’t recreate it.

See: https://docs.coronalabs.com/guide/system/composer/index.html

Without seeing any code, these are just guesses.

My first guess is that your function(s) are out of scope. If you’ve placed the functions inside scene:create() then they will only be accessible from there. So, they would be accessible if you launch your game from scene:create(), but if you leave the scene and come back, then the scene will still exist, so it won’t get recreated and so the scene:create() function doesn’t get called.

My second guess is that you don’t insert all of your display objects to display groups and/or insert those display groups or display objects to the scene group. If you are using Composer to manage your scenes, then you must insert every object or group to the scene group, otherwise Composer won’t manage them.

As to why your “Play Again” button doesn’t work, it may be the same issue that it only reloads the scene, so it doesn’t recreate it.

See: https://docs.coronalabs.com/guide/system/composer/index.html