Chapter    4

Physics & Collisions

In this chapter, you’ll learn more about editing physics properties with SpriteBuilder and how to control the player through physics rather than actions. You’ll add impenetrable physics bodies as level borders to prevent the player character from moving outside the level boundaries.

You’ll also learn about how to run code when a collision occurs—in this case, to trigger game events like ending the current level—and how to set up collision categories and masks to allow certain physics bodies to pass through each other.

Player Physics

In the previous chapter, you already added a Physics node to the Level1.ccb and made the player node a child of the newly introduced Physics node. This instance of CCPhysicsNode ...

Get Learn SpriteBuilder for iOS Game Development 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.