Chapter 10
Organizing Game Objects
You saw in the previous chapters how to use classes to group variables that belong together. This chapter looks at the similarities between the different types of game objects and how you can express these similarities in Swift.
Similarities Between Game Objects
If you look at the different game objects in the Painter game, you can see that they have a lot of things in common. For example, the ball, the cannon, and the paint cans all use three sprites that represent each of the three different colors. Also, most objects in the game have a velocity. Furthermore, some of the game objects have a method for handling input, some have an updateDelta method, and some have a reset method. Now, it isn’t really a problem ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access