Creating Object Managers
Not every Object in the scene should be something that can be seen, heard, or collided with. Some Objects can also exist with a conceptual meaning, not something tangible. Imagine you need to keep a count of the number of enemies, where do you save that? You also need someplace to save the current score of the Player, and you may be thinking it could be on the Player itself, but what happens if the Player dies and respawns? The data would be lost! In such scenarios, the concept of a Manager can be a useful way of solving this in our first games, so let's explore it.
In this chapter, we are going to see the following Object Manager concepts:
- Implementing the Singleton design pattern
- Creating Managers with Singleton
We will start by discussing what the Singleton design pattern is and how it helps us simplify the communication of Objects. With it we will create Managers Objects, which will allow us to centralize information of a group...