16

USING THE SPRITEKIT PHYSICS ENGINE

In this chapter, we’ll use SpriteKit’s physics engine in our skateboarder game. A physics engine handles physical actions in games, such as how gravity works, objects’ speeds, how things bounce off one another, and more so that you can make more complex games with less code. When coding a game, you define how the game elements (the skater, the bricks, the gems) should behave, and then the physics engine takes care of moving everything around.

For example, rather than changing the skater’s velocity when she jumps, we’ll simply tell the computer how heavy she is and then apply an upward force. This tells the ...

Get Coding iPhone Apps for Kids, 1st 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.