Game Development Reference
In-Depth Information
Class Prefix: : This is used to prefix your classes due to poor Objective-C
namespace. People often ignore this (it makes sense when you make small
projects, but if you use any third-party libraries or want to follow best
practices, use three-lettered prefixes). We will use ERG (denoting Endless
Runner Game) for this. Apple reserves using two-lettered prefixes for
internal use.
Devices : We are making the game for iPhones, so ensure iPhone is selected.
Now, save the project and click on Create .
Once you have created the project, build and run it by clicking on the play button at
the top-left corner of the window.
You will see the Hello, World! label at the center of the screen, and if you tap the
screen, you will get a rotating spaceship at that point. At the bottom-right corner of
the screen, you can see the current FPS ( frames per second ) and number of nodes
in the scene.
Anatomy of a Sprite Kit project
A Sprite Kit project consists of things usual to any iOS project. It has the
AppDelegate , Storyboard , and ViewController classes. It has the usual structure
of any iOS application. However, there are differences in ViewController.view ,
which has the SKView class in Storyboard .
You will handle everything that is related to Sprite Kit in SKView . This class will
render your gameplay elements such as sprites, nodes, backgrounds, and everything
else. You can't draw Sprite Kit elements on other views.
It's important to understand that Sprite Kit introduces its own coordinate system.
In UIkit, the origin (0,0) is located at the top-left corner, whereas Sprite Kit locates
the origin at the bottom-left corner. The reason why this is important to understand
is because of the fact that all elements will be positioned relative to the new
coordinate system. This system originates from OpenGL, which Sprite Kit uses
in implementation.
 
Search WWH ::




Custom Search