© James Goodwill and Wesley Matlock 2017

James Goodwill and Wesley Matlock, Beginning Swift Games Development for iOS, 10.1007/978-1-4842-2310-9_3

3. Adding Physics and Collision Detection to Your Game

James Goodwill and Wesley Matlock2

(1)Highlands Ranch, Colorado, USA

(2)Kansas City, Missouri, USA

This chapter covers SpriteKit’s physics engine and collision detection. We begin with a discussion of SKPhysicsBody—the class used to simulate collision detection. You will then turn on gravity in the game world and see how that affects the nodes. After that, you will add a touch responder to propel the playerNode up into space. I close this chapter with a discussion of how to handle node collisions.

What Is an SKPhysicsBody?

To simulate physics in a SpriteKit ...

Get Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit 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.