Cocos2d Framework accelerates the development of iPhone applications. The rich Cocos2d library enables the developer to quickly get the game running in action. Cocos2d includes the particles framework which can be used to create cool effects. In this article we are going to implement eye catching effects using Cocos2d particles framework.

What are Particles?

In Cocos2d particles can be described as a number of images which work together to create an effect. These effects can include snow effects, fire effects, explosion effects and more! You can even create your particles using the following application. Keep in mind the particle designer application is NOT FREE!

Particle Designer

Implementing Particles in an Application:

In order to experience the particles in action download the Cocos2d source and then run the particles tests. The particles tests will give you an idea on how the particles will look in an actual application.

There are many particles effects which are already build into the Cocos2d framework. The implementation below shows the declaration of the CCParticleSystem which is responsible for creating the particles.

 


In the implementation file we will expose the emitter as the property using the synthesize keyword as shown below:



The emitter is then initialized in the init method which it is added to the layer as shown in the implementation below:  



The CCParticleFire is one kind of the particles effects built into the Cocos2d framework. In order to use CCParticleFire include the fire.png and fire.pvr in the Resources folder. The complete implementation is shown below:



If you are curious about the firewood.png sprite then don't worry it is just an image of firewood as shown below:





The particles effect is shown in the screenshot below:



The fire effect is really amazing and it is highly recommended that you run the Cocos2d test application or this demo application to see it in action.

Creating a Ball of Fire:

The uses of particles is only limited by ones imagination. In this section we are going to demonstrate how to create a fire ball effect which can be easily utilized in any game. The ball of fire will move vertically anywhere the where the screen is touched.  
 



The step method is scheduled to be fired in small intervals and inside this method we change the coordinates of the ball of fire as shown below:



The screenshot below shows the fire ball effect in action:



Particle Effects in ABC Pop:

If you do want to see particles effects in action then get "ABC Pop" application. You will notice that whenever you pop a bubble it is exploded in smaller bubbles. This effect is created by setting the texture of the particle system to be that of an image to be used in the particles effect. You can use the following link to download the ABC Pop application.

ABC Pop

Conclusion:

Cocos2d is one of the best iPhone game development framework which provides a strong library to create attractive iPhone/iPad apps. Cocos2d particles framework allows the developers to create stunning effects which will prove vital for any iOS game.