cocos2d-iphone  2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
CCParticleSystem Class Reference

#import <CCParticleSystem.h>

Inheritance diagram for CCParticleSystem:
Collaboration diagram for CCParticleSystem:

Instance Methods

(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
 
 Instance Methods inherited from CCNode
(id) - init
 
(void) - onEnter
 
(void) - onEnterTransitionDidFinish
 
(void) - onExit
 
(void) - onExitTransitionDidStart
 
(void) - addChild:
 
(void) - addChild:z:
 
(void) - addChild:z:tag:
 
(void) - removeFromParent
 
(void) - removeFromParentAndCleanup:
 
(void) - removeChild:
 
(void) - removeChild:cleanup:
 
(void) - removeChildByTag:
 
(void) - removeChildByTag:cleanup:
 
(void) - removeAllChildren
 
(void) - removeAllChildrenWithCleanup:
 
(CCNode *) - getChildByTag:
 
(void) - reorderChild:z:
 
(void) - sortAllChildren
 
(void) - cleanup
 
(void) - draw
 
(void) - visit
 
(void) - transform
 
(void) - transformAncestors
 
(CGRect) - boundingBox
 
(CCAction *) - runAction:
 
(void) - stopAllActions
 
(void) - stopAction:
 
(void) - stopActionByTag:
 
(CCAction *) - getActionByTag:
 
(NSUInteger) - numberOfRunningActions
 
(void) - scheduleUpdate
 
(void) - scheduleUpdateWithPriority:
 
(void) - unscheduleUpdate
 
(void) - schedule:
 
(void) - schedule:interval:
 
(void) - schedule:interval:repeat:delay:
 
(void) - scheduleOnce:delay:
 
(void) - unschedule:
 
(void) - unscheduleAllSelectors
 
(void) - resumeSchedulerAndActions
 
(void) - pauseSchedulerAndActions
 
(CGAffineTransform) - nodeToParentTransform
 
(CGAffineTransform) - parentToNodeTransform
 
(CGAffineTransform) - nodeToWorldTransform
 
(CGAffineTransform) - worldToNodeTransform
 
(CGPoint) - convertToNodeSpace:
 
(CGPoint) - convertToWorldSpace:
 
(CGPoint) - convertToNodeSpaceAR:
 
(CGPoint) - convertToWorldSpaceAR:
 
(CGPoint) - convertTouchToNodeSpace:
 
(CGPoint) - convertTouchToNodeSpaceAR:
 
(void) - setIsRelativeAnchorPoint:
 
(BOOL) - DEPRECATED_ATTRIBUTE
 
(void) - setZOrder:
 
 Instance Methods inherited from <CCTextureProtocol>
(CCTexture2D *) - texture
 
(void) - setTexture:
 
 Instance Methods inherited from <CCBlendProtocol>
(void) - setBlendFunc:
 
(ccBlendFunc- blendFunc
 

Class Methods

(id) + particleWithFile:
 
(id) + particleWithTotalParticles:
 
 Class Methods inherited from CCNode
(id) + node
 

Protected Attributes

float elapsed
 
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
 
tCCParticleparticles
 
NSUInteger allocatedParticles
 
float emitCounter
 
CCTexture2Dtexture_
 
ccBlendFunc blendFunc_
 
BOOL opacityModifyRGB_
 
tCCPositionType positionType_
 
BOOL autoRemoveOnFinish_
 
NSUInteger particleIdx
 
CC_UPDATE_PARTICLE_IMP updateParticleImp
 
SEL updateParticleSel
 
CCParticleBatchNodebatchNode_
 
NSUInteger atlasIndex_
 
BOOL transformSystemDirty_
 
 Protected Attributes inherited from CCNode
float rotationX_
 
float rotationY_
 
float scaleX_
 
float scaleY_
 
float vertexZ_
 
CGPoint position_
 
float skewX_
 
float skewY_
 
CGPoint anchorPointInPoints_
 
CGPoint anchorPoint_
 
CGSize contentSize_
 
CGAffineTransform transform_
 
CGAffineTransform inverse_
 
CCCameracamera_
 
CCGridBasegrid_
 
NSInteger zOrder_
 
CCArraychildren_
 
CCNodeparent_
 
NSInteger tag_
 
void * userData_
 
id userObject_
 
CCGLProgramshaderProgram_
 
ccGLServerState glServerState_
 
NSUInteger orderOfArrival_
 
CCSchedulerscheduler_
 
CCActionManageractionManager_
 
BOOL isRunning_
 
BOOL isTransformDirty_
 
BOOL isInverseDirty_
 
BOOL visible_
 
BOOL ignoreAnchorPointForPosition_
 
BOOL isReorderChildDirty_
 

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
 
CCTexture2Dtexture
 
ccBlendFunc blendFunc
 
BOOL opacityModifyRGB
 
BOOL blendAdditive
 
tCCPositionType positionType
 
BOOL autoRemoveOnFinish
 
NSInteger emitterMode
 
CCParticleBatchNodebatchNode
 
NSUInteger atlasIndex
 
 Properties inherited from CCNode
NSInteger zOrder
 
float vertexZ
 
float skewX
 
float skewY
 
float rotation
 
float rotationX
 
float rotationY
 
float scale
 
float scaleX
 
float scaleY
 
CGPoint position
 
CCCameracamera
 
CCArraychildren
 
CCGridBasegrid
 
BOOL visible
 
CGPoint anchorPoint
 
CGPoint anchorPointInPoints
 
CGSize contentSize
 
BOOL isRunning
 
CCNodeparent
 
BOOL ignoreAnchorPointForPosition
 
NSInteger tag
 
void * userData
 
id userObject
 
CCGLProgramshaderProgram
 
NSUInteger orderOfArrival
 
ccGLServerState glServerState
 
CCActionManageractionManager
 
CCSchedulerscheduler
 

Detailed Description

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:

emitter.radialAccel = 15;
emitter.startSpin = 0;

Method Documentation

- (id) initWithDictionary: (NSDictionary *)  dictionary

initializes a particle system from a NSDictionary.

Since
v0.99.3
- (id) initWithDictionary: (NSDictionary *)  dictionary
path: (NSString *)  dirname 

initializes a particle system from a NSDictionary and the path from where to load the png

Since
v2.1
- (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/

Since
v0.99.3
- (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/

Since
v0.99.3
- (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.

Implements CCNode.

- (void) updateQuadWithParticle: (tCCParticle *)  particle
newPosition: (CGPoint)  pos 

should be overriden by subclasses

Property Documentation

- (BOOL) active
readnonatomicassign

Is the emitter active

- (float) angle
readwritenonatomicassign

angle and angle variation of each particle

- (float) angleVar
readwritenonatomicassign

angle variance of each particle

- (BOOL) autoRemoveOnFinish
readwritenonatomicassign

whether or not the node will be auto-removed when it has no particles left. By default it is NO.

Since
v0.8
- (CCParticleBatchNode*) batchNode
readwritenonatomicassign

weak reference to the CCSpriteBatchNode that renders the CCSprite

- (BOOL) blendAdditive
readwritenonatomicassign

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
readwritenonatomicassign

conforms to CocosNodeTexture protocol

- (float) duration
readwritenonatomicassign

How many seconds the emitter wil run. -1 means 'forever'

- (float) emissionRate
readwritenonatomicassign

emission rate of the particles

- (NSInteger) emitterMode
readwritenonatomicassign

Switch between different kind of emitter modes:

  • kCCParticleModeGravity: uses gravity, speed, radial and tangential acceleration
  • kCCParticleModeRadius: uses radius movement + rotation
- (ccColor4F) endColor
readwritenonatomicassign

end color and end color variation of each particle

- (ccColor4F) endColorVar
readwritenonatomicassign

end color variance of each particle

- (float) endRadius
readwritenonatomicassign

The ending radius of the particles. Only available in 'Radius' mode.

- (float) endRadiusVar
readwritenonatomicassign

The ending radius variance of the particles. Only available in 'Radius' mode.

- (float) endSize
readwritenonatomicassign

end size in pixels of each particle

- (float) endSizeVar
readwritenonatomicassign

end size variance in pixels of each particle

- (CGPoint) gravity
readwritenonatomicassign

Gravity value. Only available in 'Gravity' mode.

- (float) life
readwritenonatomicassign

life, and life variation of each particle

- (float) lifeVar
readwritenonatomicassign

life variance of each particle

- (BOOL) opacityModifyRGB
readwritenonatomicassign

does the alpha value modify color

- (NSUInteger) particleCount
readnonatomicassign

Quantity of particles that are being simulated at the moment

- (tCCPositionType) positionType
readwritenonatomicassign

particles movement type: Free or Grouped

Since
v0.8
- (CGPoint) posVar
readwritenonatomicassign

Position variance of the emitter

- (float) radialAccel
readwritenonatomicassign

radial acceleration of each particle. Only available in 'Gravity' mode.

- (float) radialAccelVar
readwritenonatomicassign

radial acceleration variance of each particle. Only available in 'Gravity' mode.

- (float) rotatePerSecond
readwritenonatomicassign

Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.

- (float) rotatePerSecondVar
readwritenonatomicassign

Variance in degrees for rotatePerSecond. Only available in 'Radius' mode.

- (CGPoint) sourcePosition
readwritenonatomicassign

sourcePosition of the emitter

- (float) speed
readwritenonatomicassign

speed of each particle. Only available in 'Gravity' mode.

- (float) speedVar
readwritenonatomicassign

speed variance of each particle. Only available in 'Gravity' mode.

- (ccColor4F) startColor
readwritenonatomicassign

start color of each particle

- (ccColor4F) startColorVar
readwritenonatomicassign

start color variance of each particle

- (float) startRadius
readwritenonatomicassign

The starting radius of the particles. Only available in 'Radius' mode.

- (float) startRadiusVar
readwritenonatomicassign

The starting radius variance of the particles. Only available in 'Radius' mode.

- (float) startSize
readwritenonatomicassign

start size in pixels of each particle

- (float) startSizeVar
readwritenonatomicassign

size variance in pixels of each particle

- (float) tangentialAccel
readwritenonatomicassign

tangential acceleration of each particle. Only available in 'Gravity' mode.

- (float) tangentialAccelVar
readwritenonatomicassign

tangential acceleration variance of each particle. Only available in 'Gravity' mode.

- (CCTexture2D*) texture
readwritenonatomicretain

conforms to CocosNodeTexture protocol

- (NSUInteger) totalParticles
readwritenonatomicassign

maximum particles of the system


The documentation for this class was generated from the following file: