There are two types of particle system in cocos2d: Quad and Point particle system
The CCParticleSystemQuad has these additional features that CCParticleSystemPoint doesn't support:
CCParticleSystemPoint ignores this property.CCParticleSystemPoint if the size is bigger than 64, it will be treated as 64.scale property. From the API docs:
To create a Point Particle System:
id particleSystem = [[CCParticleSystemPoint alloc] initWithTotalParticles:numberOfParticles];
To create a Quad Particle System:
id particleSystem = [[CCParticleSystemQuad alloc] initWithTotalParticles:numberOfParticles];
Since v0.99.3, a new mode was added: Radius Mode. The old behavior is called Gravity mode.
These properties are only valid in Gravity Mode:
gravity (a CGPoint). The gravity of the particle systemspeed (a float). The speed at which the particles are emittedspeedVar (a float). The speed variance.tangencialAccel (a float). The tangential acceleration of the particles.tangencialAccelVar (a float). The tangential acceleration variance.radialAccel (a float). The radial acceleration of the particles.radialAccelVar (a float). The radial acceleration variance.To set the particle in 'Gravity mode' (default one), you need to do these:
id particleSystem = [[CCParticleSystemQuad alloc] initWithTotalParticles:numberOfParticles]; [particleSystem setEmitterMode: kCCParticleModeGravity];
This mode is only available since v0.99.3
These properties are only valid in Radius Mode:
startRadius (a float). The starting radius of the particlesstartRadiusVar (a float). The starting radius varianceendRadius (a float). The ending radius of the particles. Use kCCParticleStartRadiusEqualToEndRadius if you want that the start radius == end radius.endRadiusVar (a float). The ending radius variancerotatePerSecond (a float). Number of degress to rotate a particle around the source pos per second.rotatePerSecondVar (a float). Number of degrees variance.To set the particle in 'Radius mode', you need to do these:
id particleSystem = [[CCParticleSystemQuad alloc] initWithTotalParticles:numberOfParticles]; [particleSystem setEmitterMode: kCCParticleModeRadius];
Common properties of the particles:
startSize: Start size of the particles in pixelsstartSizeVarendSize: Use kCCParticleStartSizeEqualToEndSize if you want that the start size == end size.endSizeVarstartColor (a ccColor4F)startColorVar (a ccColor4F)endColor (a ccColor4F)endColorVar (a ccColor4F)startSpin. Only used in CCParticleSystemQuadstartSpinVar. Only used in CCParticleSystemQuadendSpin. Only used in CCParticleSystemQuadendSpinVar. Only used in CCParticleSystemQuadlife: time to live of the particles in secondslifeVar: angle: (a float). Starting degrees of the particleangleVarpositon: (a CGPoint)posVarcenterOfGravity (a CGPoint)Common properties of the system:
emissionRate (a float). How many particle are emitted per secondduration (a float). How many seconds does the particle system (different than the life property) lives. Use kCCParticleDurationInfinity for infity.blendFunc (a ccBlendFunc). The OpenGL blending function used for the systempositionType (a tCCPositionType). Use kCCPositionTypeFree (default one) for moving particles freely. Or use kCCPositionTypeGrouped to move them in a group.texture (a CCTexture2D). The texture used for the particlescocos2d comes with some predefined particles that can be customized in runtime. List of predefined particles:
CCParticleFire: Point particle system. Uses Gravity mode.CCParticleFireworks: Point particle system. Uses Gravity mode.CCParticleSun: Point particle system. Uses Gravity mode. CCParticleGalaxy: Point particle system. Uses Gravity mode.CCParticleFlower: Point particle system. Uses Gravity mode. CCParticleMeteor: Point particle system. Uses Gravity mode. CCParticleSpiral: Point particle system. Uses Gravity mode. CCParticleExplosion: Point particle system. Uses Gravity mode.CCParticleSmoke: Point particle system. Uses Gravity mode.CCParticleSnow: Point particle system. Uses Gravity mode.CCParticleRain: Point particle system. Uses Gravity mode.Particle Designer is a tool that lets you create particles visually.
In order to use the particles created with it you should:
To load a particle created with Particle Designer you should do:
// Either you can create a Quad particle system id particleSystem = [CCParticleSystemQuad particleWithFile:@"MyParticle.plist"]; // ...or a Point particle system. id particleSystem = [CCParticleSystemQuad particleWithFile:@"MyParticle.plist"];
cocos2d supports all the Particle Designer features, but not all the cocos2d features are supported by Particle Designer.
startSpin / startSpinVar: only when using QuadsendSpin / endSpinVar: only when using QuadstangentiallAccel / tangentialAccelVar: only supported in cocos2d radialAccel / radialAccelVar: only supported in cocos2d cocos2d copied the the Radius Mode from Particle Designer, and also extended it a little bit.
Particle Designer uses these 3 properties:
maxRadiusmaxRadiusVarianceminRaidusAnd cocos2d uses these other variables:
startRadiusstartRadiusVarendRadiusendRadiusVarcocos2d emulates the Particle Designer behavior, and also offers a few more possibilities like:
There is a “feature request” already open at 71squared to support the missing features.
Particle Mint is an another tool that lets you create particles visually using your iPad or iPhone. It is available on App Store
In order to use the particles created with it you should:
To load a particle created with Particle Mint you should do:
CCParticleSystemQuad *effect = [[CCParticleSystemQuad alloc] initWithDictionary:[ParticleFactory makeEffect]];
Particle Mint is based on cocos2d-1.0-rc3, so it supports all particle system futures and show real performance on devices.