Book Image

Learning iPhone Game Development with Cocos2D 3.0

By : Kirill Muzykov
Book Image

Learning iPhone Game Development with Cocos2D 3.0

By: Kirill Muzykov

Overview of this book

Table of Contents (19 chapters)
Learning iPhone Game Development with Cocos2D 3.0
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Time for action – hitting the bird animation


Currently, when the hunter hits the bird, it just disappears from the screen. This does not look very realistic. I mean the hunter does not have some kind of disintegrator blaster or something like that, and the last time I checked the arrow does not work this way.

Let's fix this by adding falling and rotation animation:

  1. Open the Bird.m file and add the following method right below the animateFly method:

    -(void)animateFall
    {
        CGPoint fallDownOffScreenPoint = 
          ccp(self.position.x, -self.boundingBox.size.height);
        
        CCActionMoveTo *fallOffScreen = 
          [CCActionMoveTo actionWithDuration:2.0f        
                          position:fallDownOffScreenPoint];
        
        CCActionRemove *removeWhenDone = [CCActionRemove action];
    
        CCActionSequence *fallSequence =
          [CCActionSequence actions: fallOffScreen,
                                     removeWhenDone,
                                     nil];
    
        [self runAction:fallSequence];
        ...