Chapter 3
Adding Physics and Collision Detection to Your Game
In the previous chapter I covered quite a bit of information including what SKScene objects are and how they are built. I also talked about the SKScene rendering loop and how the order that the scene’s node tree is constructed in can affect the look and interactivity of the nodes. I closed the chapter with a look at a scene’s coordinate system and node anchor points.
In this chapter, I will cover Sprite Kit’s physics engine and collision detection. I will begin the chapter 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 ...
Get Beginning Swift Games Development for iOS 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.