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
-
activeIs the emitter active
property -
particleCountQuantity of particles that are being simulated at the moment
property -
durationHow many seconds the emitter wil run. -1 means ‘forever’
property -
sourcePositionsourcePosition of the emitter
property -
posVarPosition variance of the emitter
property -
lifelife, and life variation of each particle
property -
lifeVarlife variance of each particle
property -
angleangle and angle variation of each particle
property -
angleVarangle variance of each particle
property -
gravityGravity value. Only available in ‘Gravity’ mode.
property -
speedspeed of each particle. Only available in ‘Gravity’ mode.
property -
speedVarspeed variance of each particle. Only available in ‘Gravity’ mode.
property -
tangentialAcceltangential acceleration of each particle. Only available in ‘Gravity’ mode.
property -
tangentialAccelVartangential acceleration variance of each particle. Only available in ‘Gravity’ mode.
property -
radialAccelradial acceleration of each particle. Only available in ‘Gravity’ mode.
property -
radialAccelVarradial acceleration variance of each particle. Only available in ‘Gravity’ mode.
property -
startRadiusThe starting radius of the particles. Only available in ‘Radius’ mode.
property -
startRadiusVarThe starting radius variance of the particles. Only available in ‘Radius’ mode.
property -
endRadiusThe ending radius of the particles. Only available in ‘Radius’ mode.
property -
endRadiusVarThe ending radius variance of the particles. Only available in ‘Radius’ mode.
property -
rotatePerSecondNumber of degress to rotate a particle around the source pos per second. Only available in ‘Radius’ mode.
property -
rotatePerSecondVarVariance in degrees for rotatePerSecond. Only available in ‘Radius’ mode.
property -
startSizestart size in pixels of each particle
property -
startSizeVarsize variance in pixels of each particle
property -
endSizeend size in pixels of each particle
property -
endSizeVarend size variance in pixels of each particle
property -
startColorstart color of each particle
property -
startColorVarstart color variance of each particle
property -
endColorend color and end color variation of each particle
property -
endColorVarend color variance of each particle
property -
startSpinproperty -
startSpinVarproperty -
endSpinproperty -
endSpinVarproperty -
emissionRateemission rate of the particles
property -
totalParticlesmaximum particles of the system
property -
textureconforms to CocosNodeTexture protocol
property -
blendFuncconforms to CocosNodeTexture protocol
property -
opacityModifyRGBdoes the alpha value modify color
property -
blendAdditivewhether 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 -
positionTypeparticles movement type: Free or Grouped
property -
autoRemoveOnFinishwhether or not the node will be auto-removed when it has no particles left. By default it is NO.
property -
emitterModeSwitch between different kind of emitter modes: – kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration – kCCParticleModeRadius: uses radius movement + rotation
property -
batchNodeweak reference to the CCSpriteBatchNode that renders the CCSprite
property -
atlasIndexproperty -
+ 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
-
centerOfGravitycenterOfGravity of the emitter
property -
– addParticle -
– initParticle:
Properties
active
Is the emitter active
@property (nonatomic, readonly) BOOL activeDeclared In
CCParticleSystem.hangle
angle and angle variation of each particle
@property (nonatomic, readwrite, assign) float angleDeclared In
CCParticleSystem.hangleVar
angle variance of each particle
@property (nonatomic, readwrite, assign) float angleVarDeclared In
CCParticleSystem.hautoRemoveOnFinish
whether or not the node will be auto-removed when it has no particles left. By default it is NO.
@property (nonatomic, readwrite) BOOL autoRemoveOnFinishAvailability
Declared In
CCParticleSystem.hbatchNode
weak reference to the CCSpriteBatchNode that renders the CCSprite
@property (nonatomic, readwrite, assign) CCParticleBatchNode *batchNodeDeclared In
CCParticleSystem.hblendAdditive
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 blendAdditiveDeclared In
CCParticleSystem.hblendFunc
conforms to CocosNodeTexture protocol
@property (nonatomic, readwrite) ccBlendFunc blendFuncDeclared In
CCParticleSystem.hcenterOfGravity
centerOfGravity of the emitter
@property (nonatomic, readwrite, assign) CGPoint centerOfGravityDeclared In
CCParticleSystem.hduration
How many seconds the emitter wil run. -1 means ‘forever’
@property (nonatomic, readwrite, assign) float durationDeclared In
CCParticleSystem.hemissionRate
emission rate of the particles
@property (nonatomic, readwrite, assign) float emissionRateDeclared In
CCParticleSystem.hemitterMode
Switch between different kind of emitter modes: – kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration – kCCParticleModeRadius: uses radius movement + rotation
@property (nonatomic, readwrite) NSInteger emitterModeDeclared In
CCParticleSystem.hendColor
end color and end color variation of each particle
@property (nonatomic, readwrite, assign) ccColor4F endColorDeclared In
CCParticleSystem.hendColorVar
end color variance of each particle
@property (nonatomic, readwrite, assign) ccColor4F endColorVarDeclared In
CCParticleSystem.hendRadius
The ending radius of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float endRadiusDeclared In
CCParticleSystem.hendRadiusVar
The ending radius variance of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float endRadiusVarDeclared In
CCParticleSystem.hendSize
end size in pixels of each particle
@property (nonatomic, readwrite, assign) float endSizeDeclared In
CCParticleSystem.hendSizeVar
end size variance in pixels of each particle
@property (nonatomic, readwrite, assign) float endSizeVarDeclared In
CCParticleSystem.hgravity
Gravity value. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) CGPoint gravityDeclared In
CCParticleSystem.hlife
life, and life variation of each particle
@property (nonatomic, readwrite, assign) float lifeDeclared In
CCParticleSystem.hlifeVar
life variance of each particle
@property (nonatomic, readwrite, assign) float lifeVarDeclared In
CCParticleSystem.hopacityModifyRGB
does the alpha value modify color
@property (nonatomic, readwrite, getter=doesOpacityModifyRGB, assign) BOOL opacityModifyRGBDeclared In
CCParticleSystem.hparticleCount
Quantity of particles that are being simulated at the moment
@property (nonatomic, readonly) NSUInteger particleCountDeclared In
CCParticleSystem.hposVar
Position variance of the emitter
@property (nonatomic, readwrite, assign) CGPoint posVarDeclared In
CCParticleSystem.hpositionType
particles movement type: Free or Grouped
@property (nonatomic, readwrite) tCCPositionType positionTypeAvailability
Declared In
CCParticleSystem.hradialAccel
radial acceleration of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float radialAccelDeclared In
CCParticleSystem.hradialAccelVar
radial acceleration variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float radialAccelVarDeclared In
CCParticleSystem.hrotatePerSecond
Number of degress to rotate a particle around the source pos per second. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float rotatePerSecondDeclared In
CCParticleSystem.hrotatePerSecondVar
Variance in degrees for rotatePerSecond. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float rotatePerSecondVarDeclared In
CCParticleSystem.hsourcePosition
sourcePosition of the emitter
@property (nonatomic, readwrite, assign) CGPoint sourcePositionDeclared In
CCParticleSystem.hspeed
speed of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float speedDeclared In
CCParticleSystem.hspeedVar
speed variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float speedVarDeclared In
CCParticleSystem.hstartColor
start color of each particle
@property (nonatomic, readwrite, assign) ccColor4F startColorDeclared In
CCParticleSystem.hstartColorVar
start color variance of each particle
@property (nonatomic, readwrite, assign) ccColor4F startColorVarDeclared In
CCParticleSystem.hstartRadius
The starting radius of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float startRadiusDeclared In
CCParticleSystem.hstartRadiusVar
The starting radius variance of the particles. Only available in ‘Radius’ mode.
@property (nonatomic, readwrite, assign) float startRadiusVarDeclared In
CCParticleSystem.hstartSize
start size in pixels of each particle
@property (nonatomic, readwrite, assign) float startSizeDeclared In
CCParticleSystem.hstartSizeVar
size variance in pixels of each particle
@property (nonatomic, readwrite, assign) float startSizeVarDeclared In
CCParticleSystem.htangentialAccel
tangential acceleration of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float tangentialAccelDeclared In
CCParticleSystem.htangentialAccelVar
tangential acceleration variance of each particle. Only available in ‘Gravity’ mode.
@property (nonatomic, readwrite, assign) float tangentialAccelVarDeclared In
CCParticleSystem.hClass Methods
Instance Methods
initWithDictionary:
initializes a particle system from a NSDictionary.
- (id)initWithDictionary:(NSDictionary *)dictionaryAvailability
Declared In
CCParticleSystem.hinitWithDictionary:path:
initializes a particle system from a NSDictionary and the path from where to load the png
- (id)initWithDictionary:(NSDictionary *)dictionary path:(NSString *)dirnameAvailability
Declared In
CCParticleSystem.h