Summary
This chapter was mostly code. We enhanced the GameMaster
class to handle the game settings and scene management. We began the chapter by making GameMaster
handle the user interface, the player character data, and the game settings, which currently is just the volume for the background music.
We added a new UI element that displays the settings panel for the game. At the moment, it only contains the main volume control. Next, we added the necessary code in the UiController
class and the GameMaster
class to handle the display of the settings window, as well as the slider value passed from the UI component to UiController
to the GameMaster
class.
We also made the GameMaster
class into a singleton. A singleton in software engineering is a design pattern that restricts the instantiation of a class to one object. This pattern fits perfectly for GameMaster
, as we only need to have one instance of it active at any given time throughout the lifespan of the game.
We also looked at how to perform...