Game Development Reference
In-Depth Information
Figure 9-2 . The CCParticleExplosion is an example effect provided by cocos2d
Listing 9-1 shows the relevant methods used in the ParticleEffects01 example
project. By using the current particleType variable in the switch statement, the
corresponding built-in particle effect is created. Note that a CCParticleSystem
pointer is used to store the particles, so you need to use the addChild code only once
at the end of the runEffect method. Every example particle effect is derived from
CCParticleSystem .
Listing 9-1 . Using the Built-in Effects
-(void) runEffect
// remove any previous particle FX
[self removeChildByTag:1 cleanup:YES];
CCParticleSystem* system;
switch (particleType)
case ParticleTypeExplosion:
system = [CCParticleExplosion node];
case ParticleTypeFire:
system = [CCParticleFire node];
Search Nedrilad ::

Custom Search