In this chapter we will get to code and use our first design pattern. The Observer pattern is exactly what it sounds like. We will code some classes that will indeed observe another class. We will use this pattern to allow the GameEngine
class to inform other classes when they need to handle user input. This way individual classes can handle different aspects of user input.
In addition, we will code a particle system. A particle system comprises of hundreds or even thousands of graphical objects that are used to create an effect. Our particle system will look like an explosion.
Here is a summary of this chapter:
The Observer pattern
Upgrading the player's controls to handle Multitouch inputs
Using the Observer pattern for a multitouch UI controller to listen for broadcasts from the game engine
Implementing a particle system explosion
Let's start with a little bit of theory about the Observer pattern.