Chapter 4
Edges, Boundaries, and Ledges
Physics
You can probably imagine the amount code work needed to add complicated sprites that interact with each other and with the game world you create. In this game, you’ll want basic physics principles like gravity to affect every character that you add to the game. You’ll also want your sprites to have some walls or ledges to run along. However, all of the coding required to handle all of these physics-based interactions is daunting. Luckily, Sprite Kit comes with a built-in physics world. Let’s start exploring this option with your sprite and its world.
Add one line of code to the SKBPlayer.m file in the initNewPlayer method:
player.position = location;player.spriteTextures = playerTextures; ...
Get Learn Sprite Kit 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.