I believe the usual way people handle transitioning between scenes is by having a loading scene that you transition to between your main menu and level. You don’t load your level until it is needed and when you need it you create it in the loading scene. The app I worked on used this because it wasn’t possible to fit both the main menu and the level in the device’s memory at the same time.
For your options menu, if keeping your main menu in memory isn’t an issue then you probably have 2 options.
The first option is to have your options menu as a layer that sits hidden in your main menu. When you want to display the options menu, hide the main menu layer and show the options menu layer. One downside to this is that any behaviour that happens in the main menu will continue to run while the main menu isn’t visible, so you will have to remember to deal with that. For example, if you scheduled a function call to play a sound every few seconds, it will continue to do so while the main menu is still within the running scene.
The other option is using
popScene() instead of
replaceScene(). Replacing the main menu scene with the options scene will release it from memory and you will have to recreate the menu scene - and maybe even reload its assets - when you transition back. But
pushScene() keeps the current scene in memory while the new scene is used and when you use
popScene() then the new scene is removed and the old scene is used again.
Or, if you retain your main menu, then it will stay in memory when using
replaceScene(), but you will need to remember to release it when you no longer need it, or else it will take up memory.
I have also seen people mention using 1 scene and just creating their menus and levels as layers, removing “scene” layers when transitioning away and creating and adding level “scene” layers when transitioning to them, but I have personally never used this method.
And in response to your last question: When a scene is replaced, the scene object is released, so if you have not retained it then it will be removed from memory.