Chapter 6. 2D Graphics and Sprite Kit
Just about every game out there incorporates 2D graphics on some level. Even the most sophisticated 3D games use 2D elements, such as in the menu or in the in-game interface.
Creating a game that limits itself to 2D graphics is also a good way to keep your game simple. 2D is simpler than 3D, and you’ll end up with an easier-to-manage game, in terms of both gameplay and graphics. Puzzle games, for example, are a category of game that typically use 2D graphics rather than more complex 3D graphics.
2D is simpler for a number of reasons: you don’t need to worry about how objects are going to look from multiple angles, you don’t need to worry as much about lighting, and it’s often simpler to create a great-looking scene with 2D images than it is to create a 3D version of the same scene.
iOS comes with a system for creating 2D graphics, called Sprite Kit. Sprite Kit takes care of low-level graphics tasks like creating OpenGL contexts and managing textures, allowing you to focus on game-related tasks like showing your game’s sprites on the screen.
Sprite Kit was introduced in iOS 7, and is available on both iOS and OS X. The API for Sprite Kit is the same on both platforms, which makes porting your game from one platform to the other easier.
In this chapter, you’ll learn how to work with Sprite Kit to display your game’s graphics.
Getting Familiar with 2D Math
When you’re working with 2D graphics, it’s important to know at least a little bit of 2D math. ...