![]() |
cocos2d-iphone
2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
|
#import <CCParticleSystem.h>
Public Member Functions | |
(id) | - initWithFile: |
(id) | - initWithDictionary: |
(id) | - initWithDictionary:path: |
(id) | - initWithTotalParticles: |
Initializes a system with a fixed number of particles. | |
(void) | - stopSystem |
stop emitting particles. Running particles will continue to run until they die | |
(void) | - resetSystem |
Kill all living particles. | |
(BOOL) | - isFull |
whether or not the system is full | |
(void) | - updateQuadWithParticle:newPosition: |
should be overriden by subclasses | |
(void) | - postStep |
should be overriden by subclasses | |
(void) | - update: |
called in every loop. | |
(void) | - updateWithNoTime |
Static Public Member Functions | |
(id) | + particleWithFile: |
(id) | + particleWithTotalParticles: |
Protected Attributes | |
BOOL | _active |
float | _duration |
float | _elapsed |
CGPoint | _sourcePosition |
CGPoint | _posVar |
float | _angle |
float | _angleVar |
NSInteger | _emitterMode |
union { | |
struct { | |
CGPoint gravity | |
float speed | |
float speedVar | |
float tangentialAccel | |
float tangentialAccelVar | |
float radialAccel | |
float radialAccelVar | |
} A | |
struct { | |
float startRadius | |
float startRadiusVar | |
float endRadius | |
float endRadiusVar | |
float rotatePerSecond | |
float rotatePerSecondVar | |
} B | |
} | _mode |
float | _startSize |
float | _startSizeVar |
float | _endSize |
float | _endSizeVar |
float | _life |
float | _lifeVar |
ccColor4F | _startColor |
ccColor4F | _startColorVar |
ccColor4F | _endColor |
ccColor4F | _endColorVar |
float | _startSpin |
float | _startSpinVar |
float | _endSpin |
float | _endSpinVar |
tCCParticle * | _particles |
NSUInteger | _totalParticles |
NSUInteger | _particleCount |
NSUInteger | _allocatedParticles |
float | _emissionRate |
float | _emitCounter |
CCTexture2D * | _texture |
ccBlendFunc | _blendFunc |
BOOL | _opacityModifyRGB |
tCCPositionType | _positionType |
BOOL | _autoRemoveOnFinish |
NSUInteger | _particleIdx |
CC_UPDATE_PARTICLE_IMP | _updateParticleImp |
SEL | _updateParticleSel |
CCParticleBatchNode * | _batchNode |
NSUInteger | _atlasIndex |
BOOL | _transformSystemDirty |
Properties | |
BOOL | active |
NSUInteger | particleCount |
float | duration |
CGPoint | sourcePosition |
CGPoint | posVar |
float | life |
float | lifeVar |
float | angle |
float | angleVar |
float | startSize |
float | startSizeVar |
float | endSize |
float | endSizeVar |
ccColor4F | startColor |
ccColor4F | startColorVar |
ccColor4F | endColor |
ccColor4F | endColorVar |
float | startSpin |
float | startSpinVar |
float | endSpin |
float | endSpinVar |
float | emissionRate |
NSUInteger | totalParticles |
CCTexture2D * | texture |
ccBlendFunc | blendFunc |
BOOL | opacityModifyRGB |
BOOL | blendAdditive |
tCCPositionType | positionType |
BOOL | autoRemoveOnFinish |
NSInteger | emitterMode |
CCParticleBatchNode * | batchNode |
NSUInteger | atlasIndex |
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;
- (id) initWithDictionary: | (NSDictionary *) | dictionary |
initializes a particle system from a NSDictionary.
- (id) initWithDictionary: | (NSDictionary *) | dictionary | |
path: | (NSString *) | dirname | |
initializes a particle system from a NSDictionary and the path from where to load the png
- (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: | (NSUInteger) | 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) 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.
- (CCParticleBatchNode*) batchNode [read, write, assign] |
weak reference to the CCSpriteBatchNode that renders the CCSprite
- (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) 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
- (BOOL) opacityModifyRGB [read, write, assign] |
does the alpha value modify color
- (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