#import "CCParticleSystem.h"
Inherits CCNode, and CCTextureProtocol-p.
Inherited by CCParticleSystemPoint, and CCParticleSystemQuad.
Public Member Functions | |
(BOOL) | - addParticle |
Add a particle to the emitter. | |
(void) | - initParticle: |
Initializes a particle. | |
(id) | - initWithDictionary: |
(id) | - initWithFile: |
(id) | - initWithTotalParticles: |
Initializes a system with a fixed number of particles. | |
(BOOL) | - isFull |
whether or not the system is full | |
(void) | - postStep |
should be overriden by subclasses | |
(void) | - resetSystem |
Kill all living particles. | |
(void) | - stopSystem |
stop emitting particles. Running particles will continue to run until they die | |
(void) | - update: |
called in every loop. | |
(void) | - updateQuadWithParticle:newPosition: |
should be overriden by subclasses | |
Static Public Member Functions | |
(id) | + particleWithFile: |
Properties | |
BOOL | active |
float | angle |
float | angleVar |
BOOL | autoRemoveOnFinish |
BOOL | blendAdditive |
ccBlendFunc | blendFunc |
float | duration |
float | emissionRate |
NSInteger | emitterMode |
ccColor4F | endColor |
ccColor4F | endColorVar |
float | endSize |
float | endSizeVar |
float | life |
float | lifeVar |
NSUInteger | particleCount |
tCCPositionType | positionType |
CGPoint | posVar |
CGPoint | sourcePosition |
ccColor4F | startColor |
ccColor4F | startColorVar |
float | startSize |
float | startSizeVar |
CCTexture2D * | texture |
NSUInteger | totalParticles |
float | endRadius |
float | endRadiusVar |
CGPoint | gravity |
float | radialAccel |
float | radialAccelVar |
float | rotatePerSecond |
float | rotatePerSecondVar |
float | speed |
float | speedVar |
float | startRadius |
float | startRadiusVar |
float | tangentialAccel |
float | tangentialAccelVar |
Particle System base class Attributes of a Particle System:
cocos2d also supports particles generated by Particle Designer (http://particledesigner.71squared.com/). 'Radius Mode' in Particle Designer uses a fixed emit rate of 30 hz. Since that can't be guarateed in cocos2d, cocos2d uses a another approach, but the results are almost identical.
cocos2d supports all the variables used by Particle Designer plus a bit more:
It is possible to customize any of the above mentioned properties in runtime. Example:
emitter.radialAccel = 15; emitter.startSpin = 0;
- (BOOL) addParticle |
Add a particle to the emitter.
- (void) initParticle: | (tCCParticle *) | particle |
Initializes a particle.
- (id) initWithDictionary: | (NSDictionary *) | dictionary |
initializes a CCQuadParticleSystem from a NSDictionary.
- (id) initWithFile: | (NSString *) | plistFile |
initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: http://particledesigner.71squared.com/
- (id) initWithTotalParticles: | (int) | numberOfParticles |
Initializes a system with a fixed number of particles.
- (BOOL) isFull |
whether or not the system is full
+ (id) particleWithFile: | (NSString *) | plistFile |
creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer: http://particledesigner.71squared.com/
- (void) postStep |
should be overriden by subclasses
- (void) resetSystem |
Kill all living particles.
- (void) stopSystem |
stop emitting particles. Running particles will continue to run until they die
- (void) update: | (ccTime) | dt |
called in every loop.
- (void) updateQuadWithParticle: | (tCCParticle *) | particle | ||
newPosition: | (CGPoint) | pos | ||
should be overriden by subclasses
- (BOOL) active [read, assign] |
Is the emitter active
- (float) angle [read, write, assign] |
angle and angle variation of each particle
- (float) angleVar [read, write, assign] |
angle variance of each particle
- (BOOL) autoRemoveOnFinish [read, write, assign] |
whether or not the node will be auto-removed when it has no particles left. By default it is NO.
- (BOOL) blendAdditive [read, write, assign] |
whether or not the particles are using blend additive. If enabled, the following blending function will be used.
source blend function = GL_SRC_ALPHA; dest blend function = GL_ONE;
- (ccBlendFunc) blendFunc [read, write, assign] |
conforms to CocosNodeTexture protocol
- (float) duration [read, write, assign] |
How many seconds the emitter wil run. -1 means 'forever'
- (float) emissionRate [read, write, assign] |
emission rate of the particles
- (NSInteger) emitterMode [read, write, assign] |
Switch between different kind of emitter modes:
- (ccColor4F) endColor [read, write, assign] |
end color and end color variation of each particle
- (ccColor4F) endColorVar [read, write, assign] |
end color variance of each particle
- (float) endRadius [read, write, assign] |
The ending radius of the particles. Only available in 'Radius' mode.
- (float) endRadiusVar [read, write, assign] |
The ending radius variance of the particles. Only available in 'Radius' mode.
- (float) endSize [read, write, assign] |
end size in pixels of each particle
- (float) endSizeVar [read, write, assign] |
end size variance in pixels of each particle
- (CGPoint) gravity [read, write, assign] |
Gravity value. Only available in 'Gravity' mode.
- (float) life [read, write, assign] |
life, and life variation of each particle
- (float) lifeVar [read, write, assign] |
life variance of each particle
- (NSUInteger) particleCount [read, assign] |
Quantity of particles that are being simulated at the moment
- (tCCPositionType) positionType [read, write, assign] |
particles movement type: Free or Grouped
- (CGPoint) posVar [read, write, assign] |
Position variance of the emitter
- (float) radialAccel [read, write, assign] |
radial acceleration of each particle. Only available in 'Gravity' mode.
- (float) radialAccelVar [read, write, assign] |
radial acceleration variance of each particle. Only available in 'Gravity' mode.
- (float) rotatePerSecond [read, write, assign] |
Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
- (float) rotatePerSecondVar [read, write, assign] |
Variance in degrees for rotatePerSecond. Only available in 'Radius' mode.
- (CGPoint) sourcePosition [read, write, assign] |
sourcePosition of the emitter
- (float) speed [read, write, assign] |
speed of each particle. Only available in 'Gravity' mode.
- (float) speedVar [read, write, assign] |
speed variance of each particle. Only available in 'Gravity' mode.
- (ccColor4F) startColor [read, write, assign] |
start color of each particle
- (ccColor4F) startColorVar [read, write, assign] |
start color variance of each particle
- (float) startRadius [read, write, assign] |
The starting radius of the particles. Only available in 'Radius' mode.
- (float) startRadiusVar [read, write, assign] |
The starting radius variance of the particles. Only available in 'Radius' mode.
- (float) startSize [read, write, assign] |
start size in pixels of each particle
- (float) startSizeVar [read, write, assign] |
size variance in pixels of each particle
- (float) tangentialAccel [read, write, assign] |
tangential acceleration of each particle. Only available in 'Gravity' mode.
- (float) tangentialAccelVar [read, write, assign] |
tangential acceleration variance of each particle. Only available in 'Gravity' mode.
- (CCTexture2D*) texture [read, write, retain] |
conforms to CocosNodeTexture protocol
- (NSUInteger) totalParticles [read, write, assign] |
maximum particles of the system