CCParticleSystem Class Reference
Inherits from | CCNode : NSObject |
Conforms to | CCTextureProtocol |
Declared in | CCParticleSystem.h |
Overview
Particle System base class Attributes of a Particle System:
- emmision rate of the particles
- Gravity Mode (Mode A):
- gravity
- direction
- speed +- variance
- tangential acceleration +- variance
- radial acceleration +- variance
- Radius Mode (Mode B):
- startRadius +- variance
- endRadius +- variance
- rotate +- variance
- Properties common to all modes:
- life +- life variance
- start spin +- variance
- end spin +- variance
- start size +- variance
- end size +- variance
- start color +- variance
- end color +- variance
- life +- variance
- blending function
- texture
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:
- spinning particles (supported when using CCParticleSystemQuad)
- tangential acceleration (Gravity mode)
- radial acceleration (Gravity mode)
- radius direction (Radius mode) (Particle Designer supports outwards to inwards direction only)
It is possible to customize any of the above mentioned properties in runtime. Example:
@code
emitter.radialAccel = 15;
emitter.startSpin = 0;
@endcode
Tasks
Other Methods
-
active
Is the emitter active
property -
particleCount
Quantity of particles that are being simulated at the moment
property -
duration
How many seconds the emitter wil run. -1 means ‘forever’
property -
sourcePosition
sourcePosition of the emitter
property -
posVar
Position variance of the emitter
property -
life
life, and life variation of each particle
property -
lifeVar
life variance of each particle
property -
angle
angle and angle variation of each particle
property -
angleVar
angle variance of each particle
property -
gravity
Gravity value. Only available in ‘Gravity’ mode.
property -
speed
speed of each particle. Only available in ‘Gravity’ mode.
property -
speedVar
speed variance of each particle. Only available in ‘Gravity’ mode.
property -
tangentialAccel
tangential acceleration of each particle. Only available in ‘Gravity’ mode.
property -
tangentialAccelVar
tangential acceleration variance of each particle. Only available in ‘Gravity’ mode.
property -
radialAccel
radial acceleration of each particle. Only available in ‘Gravity’ mode.
property -
radialAccelVar
radial acceleration variance of each particle. Only available in ‘Gravity’ mode.
property -
startRadius
The starting radius of the particles. Only available in ‘Radius’ mode.
property -
startRadiusVar
The starting radius variance of the particles. Only available in ‘Radius’ mode.
property -
endRadius
The ending radius of the particles. Only available in ‘Radius’ mode.
property -
endRadiusVar
The ending radius variance of the particles. Only available in ‘Radius’ mode.
property -
rotatePerSecond
Number of degress to rotate a particle around the source pos per second. Only available in ‘Radius’ mode.
property -
rotatePerSecondVar
Variance in degrees for rotatePerSecond. Only available in ‘Radius’ mode.
property -
startSize
start size in pixels of each particle
property -
startSizeVar
size variance in pixels of each particle
property -
endSize
end size in pixels of each particle
property -
endSizeVar
end size variance in pixels of each particle
property -
startColor
start color of each particle
property -
startColorVar
start color variance of each particle
property -
endColor
end color and end color variation of each particle
property -
endColorVar
end color variance of each particle
property -
startSpin
property -
startSpinVar
property -
endSpin
property -
endSpinVar
property -
emissionRate
emission rate of the particles
property -
totalParticles
maximum particles of the system
property -
texture
conforms to CocosNodeTexture protocol
property -
blendFunc
conforms to CocosNodeTexture protocol
property -
opacityModifyRGB
does the alpha value modify color
property -
blendAdditive
whether or not the particles are using blend additive. If enabled, the following blending function will be used. @code
source blend function = GL_SRC_ALPHA; dest blend function = GL_ONE;
@endcode
property -
positionType
particles movement type: Free or Grouped
property -
autoRemoveOnFinish
whether or not the node will be auto-removed when it has no particles left. By default it is NO.
property -
emitterMode
Switch between different kind of emitter modes: – kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration – kCCParticleModeRadius: uses radius movement + rotation
property -
batchNode
weak reference to the CCSpriteBatchNode that renders the CCSprite
property -
atlasIndex
property -
+ particleWithFile:
creates an initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer:
http://particledesigner.71squared.com/
-
+ particleWithTotalParticles:
-
– initWithFile:
initializes a CCParticleSystem from a plist file. This plist files can be creted manually or with Particle Designer:
http://particledesigner.71squared.com/
-
– initWithDictionary:
initializes a particle system from a NSDictionary.
-
– initWithDictionary:path:
initializes a particle system from a NSDictionary and the path from where to load the png
-
– initWithTotalParticles:
-
– stopSystem
-
– resetSystem
-
– isFull
-
– updateQuadWithParticle:newPosition:
-
– postStep
-
– update:
-
– updateWithNoTime
Other Methods
-
centerOfGravity
centerOfGravity of the emitter
property -
– addParticle
-
– initParticle:
Properties
active
Is the emitter active
@property (nonatomic, readonly) BOOL active
Declared In
CCParticleSystem.h
angle
angle and angle variation of each particle
@property (nonatomic, readwrite, assign) float angle
Declared In
CCParticleSystem.h
angleVar
angle variance of each particle
@property (nonatomic, readwrite, assign) float angleVar
Declared In
CCParticleSystem.h
autoRemoveOnFinish
whether or not the node will be auto-removed when it has no particles left. By default it is NO.
@property (nonatomic, readwrite) BOOL autoRemoveOnFinish
Availability
Declared In
CCParticleSystem.h
batchNode
weak reference to the CCSpriteBatchNode that renders the CCSprite
@property (nonatomic, readwrite, assign) CCParticleBatchNode *batchNode
Declared In
CCParticleSystem.h
blendAdditive
whether or not the particles are using blend additive. If enabled, the following blending function will be used. @code
source blend function = GL_SRC_ALPHA;
dest blend function = GL_ONE;
@endcode
@property (nonatomic, readwrite) BOOL blendAdditive
Declared In
CCParticleSystem.h
blendFunc
conforms to CocosNodeTexture protocol
@property (nonatomic, readwrite) ccBlendFunc blendFunc
Declared In
CCParticleSystem.h
centerOfGravity
centerOfGravity of the emitter
@property (nonatomic, readwrite, assign) CGPoint centerOfGravity
Declared In
CCParticleSystem.h
duration
How many seconds the emitter wil run. -1 means ‘forever’
@property (nonatomic, readwrite, assign) float duration
Declared In
CCParticleSystem.h
emissionRate
emission rate of the particles
@property (nonatomic, readwrite, assign) float emissionRate
Declared In
CCParticleSystem.h
emitterMode
Switch between different kind of emitter modes: – kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration – kCCParticleModeRadius: uses radius movement + rotation
@property (nonatomic, readwrite) NSInteger emitterMode
Declared In
CCParticleSystem.h
endColor
end color and end color variation of each particle
@property (nonatomic, readwrite, assign) ccColor4F endColor
Declared In
CCParticleSystem.h
endColorVar
end color variance of each particle
@property (nonatomic, readwrite, assign) ccColor4F endColorVar
Declared In
CCParticleSystem.h
endRadius
The ending radius of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float endRadius
Declared In
CCParticleSystem.h
endRadiusVar
The ending radius variance of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float endRadiusVar
Declared In
CCParticleSystem.h
endSize
end size in pixels of each particle
@property (nonatomic, readwrite, assign) float endSize
Declared In
CCParticleSystem.h
endSizeVar
end size variance in pixels of each particle
@property (nonatomic, readwrite, assign) float endSizeVar
Declared In
CCParticleSystem.h
gravity
Gravity value. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) CGPoint gravity
Declared In
CCParticleSystem.h
life
life, and life variation of each particle
@property (nonatomic, readwrite, assign) float life
Declared In
CCParticleSystem.h
lifeVar
life variance of each particle
@property (nonatomic, readwrite, assign) float lifeVar
Declared In
CCParticleSystem.h
opacityModifyRGB
does the alpha value modify color
@property (nonatomic, readwrite, getter=doesOpacityModifyRGB, assign) BOOL opacityModifyRGB
Declared In
CCParticleSystem.h
particleCount
Quantity of particles that are being simulated at the moment
@property (nonatomic, readonly) NSUInteger particleCount
Declared In
CCParticleSystem.h
posVar
Position variance of the emitter
@property (nonatomic, readwrite, assign) CGPoint posVar
Declared In
CCParticleSystem.h
positionType
particles movement type: Free or Grouped
@property (nonatomic, readwrite) tCCPositionType positionType
Availability
Declared In
CCParticleSystem.h
radialAccel
radial acceleration of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float radialAccel
Declared In
CCParticleSystem.h
radialAccelVar
radial acceleration variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float radialAccelVar
Declared In
CCParticleSystem.h
rotatePerSecond
Number of degress to rotate a particle around the source pos per second. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float rotatePerSecond
Declared In
CCParticleSystem.h
rotatePerSecondVar
Variance in degrees for rotatePerSecond. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float rotatePerSecondVar
Declared In
CCParticleSystem.h
sourcePosition
sourcePosition of the emitter
@property (nonatomic, readwrite, assign) CGPoint sourcePosition
Declared In
CCParticleSystem.h
speed
speed of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float speed
Declared In
CCParticleSystem.h
speedVar
speed variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float speedVar
Declared In
CCParticleSystem.h
startColor
start color of each particle
@property (nonatomic, readwrite, assign) ccColor4F startColor
Declared In
CCParticleSystem.h
startColorVar
start color variance of each particle
@property (nonatomic, readwrite, assign) ccColor4F startColorVar
Declared In
CCParticleSystem.h
startRadius
The starting radius of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float startRadius
Declared In
CCParticleSystem.h
startRadiusVar
The starting radius variance of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float startRadiusVar
Declared In
CCParticleSystem.h
startSize
start size in pixels of each particle
@property (nonatomic, readwrite, assign) float startSize
Declared In
CCParticleSystem.h
startSizeVar
size variance in pixels of each particle
@property (nonatomic, readwrite, assign) float startSizeVar
Declared In
CCParticleSystem.h
tangentialAccel
tangential acceleration of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float tangentialAccel
Declared In
CCParticleSystem.h
tangentialAccelVar
tangential acceleration variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float tangentialAccelVar
Declared In
CCParticleSystem.h
Class Methods
Instance Methods
initWithDictionary:
initializes a particle system from a NSDictionary.
- (id)initWithDictionary:(NSDictionary *)dictionary
Availability
Declared In
CCParticleSystem.h
initWithDictionary:path:
initializes a particle system from a NSDictionary and the path from where to load the png
- (id)initWithDictionary:(NSDictionary *)dictionary path:(NSString *)dirname
Availability
Declared In
CCParticleSystem.h