Menu Time
Update this week
Most of them are UI related content. This week we mainly laid out the Menu and Setting pages.
Menu
As shown in the picture above, in this scenario, we added multiple buttons to implement different interface navigation. The first four buttons correspond to different levels of game scenes, and the last button is used to enter the setting scene. All Menu and Setting buttons are pre-arranged in the scene and the corresponding events are bound.
The code in the Controller is as follows, where the `SwitchToLevel` function is used to switch to the corresponding game scene, the `SwitchToSetting` function is used to display the setting interface, the `SwitchToMenu` function is used to return to the Menu interface, and the `SwitchMusic` function is used to switch background music In the playback state, these functions are called through instances of GameManager.
public void SwitchToLevel(int level) { GameManager.Instance.BuildLevel(level); } public void SwitchToSetting() { // show setting panel GameManager.Instance.ShowSetting(); } public void SwitchToMenu() { SceneManager.LoadScene("Menu"); } public void SwitchMusic() { GameManager.Instance.backgroundMusic = !GameManager.Instance.backgroundMusic; }
GameManager
In order to achieve global game control and setting control, we created a new GameManager class in Script. This class is a singleton class used to manage the global state of the game, including the current game level, current game status, and current background music playback. status, etc. When this class is called for the first time during the entire game, an instance of GameManager will be automatically created, and a new GameObject of DontDestroyOnLoad will be added to save the instance of GameManager. This can ensure that the instance of GameManager is available throughout the entire life cycle of the game. They all exist to prevent the game state from being lost due to interface switching.
What's next week
The next week will focus on improving the game control in GameManager, including game level control, current score, and music playback control.
Breakout Plus
Status | Prototype |
Author | liuyufeng123 |
Genre | Shooter |
More posts
- DocumentMay 31, 2024
- Enemy and gameplayMay 23, 2024
- Game TestingMay 23, 2024
- Basic level elementMay 08, 2024
- Saddle upApr 27, 2024
- Block Breaker Plus Concept!Apr 19, 2024
Leave a comment
Log in with itch.io to leave a comment.