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 ...

Get Swift Game Programming for Absolute Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.