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 – adding the feathers explosion


We are going to add an explosion of feathers when the arrow hits the bird. We will create about 100 feather particles at the bird's center point and then explode them in different directions gradually fading away.

To do this, we are going to add a few methods into the Bird.m file and call it when an arrow hits the bird. After that, we will just add our particle image to the project and we are done. Refer to the following steps:

  1. We will start by adding the method that creates a particle system. Go ahead and open the Bird.m file, and add the following method right above the removeBird: method:

    -(void)explodeFeathers
    {
        //1
        int totalNumberOfFeathers = 100;
        
        //2
        CCParticleSystem *explosion = 
          [CCParticleSystem
            particleWithTotalParticles:totalNumberOfFeathers];
        
        //3
        explosion.position = self.position;
        
        //4
        explosion.emitterMode = CCParticleSystemModeGravity;
        
        //5
        explosion.gravity...