Now that we have animation frames ready, we can animate our game objects. We're not going to make a hunter shoot in this chapter, so let's start with the bird.
Open the
Bird.m
file and import the following headers at the top:#import "cocos2d.h" #import "CCAnimation.h"
Then, add the
animateFly
method, below theinitWithBirdType:
method as follows:-(void)animateFly { //1 NSString *animFrameNameFormat; switch (self.birdType) { case BirdTypeBig: animFrameNameFormat = @"bird_big_%d.png"; break; case BirdTypeMedium: animFrameNameFormat = @"bird_middle_%d.png"; break; case BirdTypeSmall: animFrameNameFormat = @"bird_small_%d.png"; break; default: CCLOG(@"Unknown bird type, using small bird anim.!"); animFrameNameFormat = @"bird_small_%d.png"; break; } //2 NSMutableArray *animFrames = ...