Chapter 7. Implementing Collision Events

So far, we have let the SpriteKit physics simulation detect and handle collisions between game objects. You have seen that Pierre Penguin sends enemies and coins flying off into space when he flies into them. This is because the physics simulation automatically monitors collisions and sets the post-collision trajectory and velocity of each colliding body. In this chapter, we will add our own game logic when two objects come into contact: taking damage from enemies, granting the player invulnerability after touching the star, and tracking points as the player collects coins. The game will become more fun to play as the game mechanics come to life.

The topics in this chapter include the following:

  • Learning ...

Get Swift Game Development - Third Edition 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.