Scenes are the backbone of your project in RMMV. There are many scenes such as the map scene, menu scene, and battle scene. If you plan on adding new menus in your game, scenes are an important concept to understand. So, what’s a scene?
What’s A Scene
Scenes are parts of your game that contain and showcase an element of your game. Similar to how a director may have a battle scene which showcases a battle. Now, scenes in code are different; scenes act as containers.
Scenes in code contain the windows, sprites, information and game logic for how the scene should run; they’re like a big bag with a life cycle. This is because anything in your program eventually has to be terminated, so what’s the life cycle of a scene like?
Scene Life Cycle
The game logic and all the assets contained within the scene exist within the scene’s life cycle. The life cycle of a scene is handled by the create, start, update, and terminate methods. First, the important parts are created; this is when the windows, sprites, and any important properties are created. Next, the scene is started; when the scene starts, processing of information and game logic begins, which is when we begin the update loop. The update loop is where the main game logic that keeps the scene running every frame is processed; taking input from the player and managing states goes here. Finally, if the scene ever needs to be changed, the scene terminate method is called; this method is usually called by user input or game logic. Now, moving from scene to scene requires using the SceneManager class.
Scene To Scene
Unless your coding, switching scenes manually is something you won’t do. However, to go from scene to scene requires using the SceneManager.
The SceneManager changes the scene for the player and has two key methods: goto and push. Using these correct is crucial to managing scenes correctly, or your game might explode.
When To Use Goto & Push
The goto method in the SceneManager class goes directly to a scene. This is great to use if you want to go from one non-relatable scene to the next. But, if you’re going into a menu from a menu, consider using push instead.
The push method goes to the new scene, but if you use the pop method on a scene, you’ll return to the previous scene. Push is almost always better to use for menus. For creating scenes like game over, use goto instead.
For those who develop and creates new scenes in RMMV, any information you’d like to add? Comment down below!!