Book Image

Cocos2d Game Development Blueprints

By : Jorge Jordán
Book Image

Cocos2d Game Development Blueprints

By: Jorge Jordán

Overview of this book

Table of Contents (15 chapters)
Cocos2d Game Development Blueprints
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

2-star challenge – create explosions


Now that we are able to detect when a UFO is destroyed, it would be more realistic to make them explode, and I think you're ready to develop this by yourself.

Create one explosion whenever a spaceship is destroyed by using the file explosion.png that you will find in the Resources folder.

The solution

You will need to go back a few pages to achieve this challenge because in this case, we're going to create a CCParticleSystemModeRadius particle.

First of all, add explosion.png to the project and then add the following lines inside the method detectCollisions, after [_ufosToRemove addObject:ufo];:

CCParticleExplosion *explosion = [CCParticleExplosion node];
    explosion.texture = [CCTexture textureWithFile:@"explosion.png"];
         explosion.emitterMode = CCParticleSystemModeRadius;
         explosion.startSize = 100.0;
         explosion.startRadius = 20.0;
         explosion.endSize = 1.0;
         explosion.endRadius = 100.0;
         explosion.totalParticles...