What we need is a way for the GameEngine
class to send touch data to the UIController
class that we will code later in this chapter and later (in the next chapter) the PlayerController
class. We need to separate responsibility for different parts of touch handling because we want the UIController
and the PlayerController
to be responsible for handling the aspects of control related to them. It makes sense, the UIController
knows all about the UI and how to respond and the PlayerController
knows all about controlling the player. Making the GameEngine
in charge of all such things is bad encapsulation and very hard to achieve anyway.
In the first three projects our main game-engine-like class did handle all the touch data but the price of that was that each and every object was declared and managed from the game-engine-like class. We don't want to do it like that this time. We are moving on to a better encapsulated place. In the Snake project we did half a job on it. We...