Skip to Main Content
Learning iPhone Game Development with Cocos2D 3.0
book

Learning iPhone Game Development with Cocos2D 3.0

by Kirill Muzykov
June 2014
Beginner to intermediate content levelBeginner to intermediate
434 pages
9h 49m
English
Packt Publishing
Content preview from Learning iPhone Game Development with Cocos2D 3.0

Time for action – animating the birds

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.

  1. Open the Bird.m file and import the following headers at the top:
    #import "cocos2d.h"
    #import "CCAnimation.h"
  2. Then, add the animateFly method, below the initWithBirdType: 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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

Beginning Swift Games Development for iOS: Develop 2D and 3D games Using Apple's SceneKit and SpriteKit

James Goodwill, Wesley Matlock

Publisher Resources

ISBN: 9781782160144Supplemental Content