O'Reilly logo

iOS 7 Game Development by Dmitry Volevodz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding animations to our project

In order to add animations to our endless runner game, we need to perform the following steps:

  1. Find run.atlas, shield.atlas, deplete.atlas, and jump.atlas in the resources for this chapter. Drag-and-drop them into the project and be sure to check Copy items into destination group's folder.
  2. Add the following property to ERGPlayer.h. We will use it to store animation frames:
     @property (strong, nonatomic) NSMutableArray *runFrames;
  3. Add the following code at the end of the ERGPlayer.m init method:
            [self setupAnimations];
        
            [self runAction:[SKAction repeatActionForever:[SKAction animateWithTextures:self.runFrames timePerFrame:0.05 resize:YES restore:NO]] withKey:@"running"]; 

    First, we will call the setupAnimations function, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required