Class Index | File Index

Classes


Class cc.ParticleSystem


Extends cc.Node.

Defined in: CCParticleSystem.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

Particle System base class.

Method Summary
Method Attributes Method Name and Description
 
Add a particle to the emitter
<static>  
cc.ParticleSystem.create(plistFile)

return the string found by key in dict.

<static>  
cc.ParticleSystem.createWithTotalParticles(number_of_particles)
 
ctor()
Constructor
 
 
Return angle of each particle
 
Return angle variance of each particle
 
return index of system in batch node array
 
return weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
 
get BlendFunc of Particle System
 
return bounding box of particle system in world space
 
Return DrawMode of ParticleSystem
 
How many seconds the emitter wil run.
 
get emission rate of the particles
 
return kind of emitter modes
 
get end color and end color variation of each particle
 
get end color variance of each particle
 
Return ending radius of the particles.
 
Return ending radius variance of the particles.
 
get end size in pixels of each particle
 
get end size variance in pixels of each particle
 
get end angle of each particle
 
get end angle variance of each particle
 
Return Gravity of emitter
 
Return life of each particle
 
Return life variance of each particle
 
does the alpha value modify color getter
 
Quantity of particles that are being simulated at the moment
 
get particles movement type: Free or Grouped
 
Return Position variance of the emitter
 
Return radial acceleration of each particle.
 
Return radial acceleration variance of each particle.
 
get Number of degress to rotate a particle around the source pos per second.
 
Return Variance in degrees for rotatePerSecond.
 
Return ShapeType of ParticleSystem
 
Return sourcePosition of the emitter
 
Return Speed of each particle
 
return speed variance of each particle.
 
set start color of each particle
 
get start color variance of each particle
 
Return starting radius of the particles.
 
Return starting radius variance of the particles.
 
get start size in pixels of each particle
 
get size variance in pixels of each particle
 
get initial angle of each particle
 
get initial angle variance of each particle
 
Return tangential acceleration of each particle.
 
Return tangential acceleration variance of each particle.
 
get Texture of Particle System
 
get maximum particles of the system
 
init()
initializes a cc.ParticleSystem
 
initParticle(particle)
Initializes a particle
 
initWithDictionary(dictionary)
initializes a CCQuadParticleSystem from a CCDictionary.
 
initWithFile(plistFile)

initializes a CCParticleSystem from a plist file.

 
initWithTotalParticles(numberOfParticles)
Initializes a system with a fixed number of particles
 
Return ParticleSystem is active
 

return whether or not the node will be auto-removed when it has no particles left.

 

whether or not the particles are using blend additive.

 
whether or not the system is full
 
should be overriden by subclasses
 
Kill all living particles.
 
setAngle(angle)
angle of each particle setter
 
setAngleVar(angleVar)
angle variance of each particle setter
 
setAtlasIndex(atlasIndex)
set index of system in batch node array
 
setAutoRemoveOnFinish(isAutoRemoveOnFinish)

set whether or not the node will be auto-removed when it has no particles left.

 
setBatchNode(batchNode)
set weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
 
setBlendAdditive(isBlendAdditive)

whether or not the particles are using blend additive.

 
setBlendFunc(src, dst)
set BlendFunc of Particle System
 
setDrawMode(drawMode)
DrawMode of ParticleSystem setter
 
setDuration(duration)
set run seconds of the emitter
 
setEmissionRate(emissionRate)
set emission rate of the particles
 
setEmitterMode(emitterMode)

Switch between different kind of emitter modes:
- CCPARTICLE_MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration
- CCPARTICLE_MODE_RADIUS: uses radius movement + rotation

 
setEndColor(endColor)
set end color and end color variation of each particle
 
setEndColorVar(endColorVar)
set end color variance of each particle
 
setEndRadius(endRadius)
ending radius of the particles setter.
 
setEndRadiusVar(endRadiusVar)
ending radius variance of the particles setter.
 
setEndSize(endSize)
set end size in pixels of each particle
 
setEndSizeVar(endSizeVar)
set end size variance in pixels of each particle
 
setEndSpin(endSpin)
set end angle of each particle
 
setEndSpinVar(endSpinVar)
set end angle variance of each particle
 
setGravity(gravity)
Gravity of emitter setter
 
setLife(life)
life of each particle setter
 
setLifeVar(lifeVar)
life variance of each particle setter
 
does the alpha value modify color setter
 
setParticleCount(particleCount)
Quantity of particles setter
 
setPositionType(positionType)
set particles movement type: Free or Grouped
 
setPosVar(posVar)
Position variance of the emitter setter
 
setRadialAccel(radialAccel)
radial acceleration of each particle setter.
 
setRadialAccelVar(radialAccelVar)
radial acceleration variance of each particle setter.
 
set Number of degress to rotate a particle around the source pos per second.
 
Variance in degrees for rotatePerSecond setter.
 
setRotation(newRotation)
 
setScale(scale, scaleY)
 
setScaleX(newScaleX)
 
setScaleY(newScaleY)
 
setShapeType(shapeType)
ShapeType of ParticleSystem setter
 
setSourcePosition(sourcePosition)
sourcePosition of the emitter setter
 
setSpeed(speed)
Speed of each particle setter
 
setSpeedVar(speedVar)
speed variance of each particle setter.
 
setStartColor(startColor)
get start color of each particle
 
setStartColorVar(startColorVar)
set start color variance of each particle
 
setStartRadius(startRadius)
starting radius of the particles setter.
 
setStartRadiusVar(startRadiusVar)
starting radius variance of the particles setter.
 
setStartSize(startSize)
set start size in pixels of each particle
 
setStartSizeVar(startSizeVar)
set size variance in pixels of each particle
 
setStartSpin(startSpin)
set initial angle of each particle
 
setStartSpinVar(startSpinVar)
set initial angle variance of each particle
 
setTangentialAccel(tangentialAccel)
Tangential acceleration of each particle setter.
 
setTangentialAccelVar(tangentialAccelVar)
tangential acceleration variance of each particle setter.
 
setTexture(texture)
set Texture of Particle System
 
setTotalParticles(totalParticles)
set maximum particles of the system
 
stop emitting particles.
 
update(dt)
update emitter's status
 
updateQuadWithParticle(particle, newPosition)
should be overriden by subclasses
 
Methods borrowed from class cc.Node:
addChild, cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, description, draw, getActionByTag, getActionManager, getAnchorPoint, getAnchorPointInPoints, getBoundingBox, getCamera, getChildByTag, getChildren, getChildrenCount, getContentSize, getGLServerState, getGrid, getOrderOfArrival, getParent, getPosition, getPositionX, getPositionY, getRotation, getScale, getScaleX, getScaleY, getScheduler, getShaderProgram, getSkewX, getSkewY, getTag, getUserData, getUserObject, getVertexZ, getZOrder, ignoreAnchorPointForPosition, isIgnoreAnchorPointForPosition, isRunning, isVisible, nodeToParentTransform, nodeToWorldTransform, numberOfRunningActions, onEnter, onEnterTransitionDidFinish, onExit, onExitTransitionDidStart, parentToNodeTransform, pauseSchedulerAndActions, release, removeAllChildren, removeAllChildrenWithCleanup, removeChild, removeChildByTag, removeFromParent, removeFromParentAndCleanup, reorderChild, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setContentSize, setGLServerState, setGrid, setNodeDirty, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, sortAllChildren, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, updateTransform, visit, worldToNodeTransform
Class Detail
cc.ParticleSystem()

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 Detail
{Boolean} addParticle()
Add a particle to the emitter
Returns:
{Boolean}

<static> {cc.ParticleSystem} cc.ParticleSystem.create(plistFile)

return the string found by key in dict.
This plist files can be creted manually or with Particle Designer:
http://particledesigner.71squared.com/

Parameters:
{String} plistFile
Returns:
{cc.ParticleSystem}

<static> cc.ParticleSystem.createWithTotalParticles(number_of_particles)
Parameters:
number_of_particles

ctor()
Constructor

destroyParticleSystem()

{Number} getAngle()
Return angle of each particle
Returns:
{Number}

{Number} getAngleVar()
Return angle variance of each particle
Returns:
{Number}

{Number} getAtlasIndex()
return index of system in batch node array
Returns:
{Number}

{cc.ParticleBatchNode} getBatchNode()
return weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
Returns:
{cc.ParticleBatchNode}

{cc.BlendFunc} getBlendFunc()
get BlendFunc of Particle System
Returns:
{cc.BlendFunc}

{cc.Rect} getBoundingBoxToWorld()
return bounding box of particle system in world space
Returns:
{cc.Rect}

{Number} getDrawMode()
Return DrawMode of ParticleSystem
Returns:
{Number}

{Number} getDuration()
How many seconds the emitter wil run. -1 means 'forever'
Returns:
{Number}

{Number} getEmissionRate()
get emission rate of the particles
Returns:
{Number}

{Number} getEmitterMode()
return kind of emitter modes
Returns:
{Number}

{cc.Color4F} getEndColor()
get end color and end color variation of each particle
Returns:
{cc.Color4F}

{cc.Color4F} getEndColorVar()
get end color variance of each particle
Returns:
{cc.Color4F}

{Number} getEndRadius()
Return ending radius of the particles. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getEndRadiusVar()
Return ending radius variance of the particles. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getEndSize()
get end size in pixels of each particle
Returns:
{Number}

{Number} getEndSizeVar()
get end size variance in pixels of each particle
Returns:
{Number}

{Number} getEndSpin()
get end angle of each particle
Returns:
{Number}

{Number} getEndSpinVar()
get end angle variance of each particle
Returns:
{Number}

{cc.Point} getGravity()
Return Gravity of emitter
Returns:
{cc.Point}

{Number} getLife()
Return life of each particle
Returns:
{Number}

{Number} getLifeVar()
Return life variance of each particle
Returns:
{Number}

{Boolean} getOpacityModifyRGB()
does the alpha value modify color getter
Returns:
{Boolean}

{Number} getParticleCount()
Quantity of particles that are being simulated at the moment
Returns:
{Number}

{Number} getPositionType()
get particles movement type: Free or Grouped
Returns:
{Number}

{cc.Point} getPosVar()
Return Position variance of the emitter
Returns:
{cc.Point}

{Number} getRadialAccel()
Return radial acceleration of each particle. Only available in 'Gravity' mode.
Returns:
{Number}

{Number} getRadialAccelVar()
Return radial acceleration variance of each particle. Only available in 'Gravity' mode.
Returns:
{Number}

{Number} getRotatePerSecond()
get Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getRotatePerSecondVar()
Return Variance in degrees for rotatePerSecond. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getShapeType()
Return ShapeType of ParticleSystem
Returns:
{Number}

{cc.Point} getSourcePosition()
Return sourcePosition of the emitter
Returns:
{cc.Point}

{Number} getSpeed()
Return Speed of each particle
Returns:
{Number}

{Number} getSpeedVar()
return speed variance of each particle. Only available in 'Gravity' mode.
Returns:
{Number}

{cc.Color4F} getStartColor()
set start color of each particle
Returns:
{cc.Color4F}

{cc.Color4F} getStartColorVar()
get start color variance of each particle
Returns:
{cc.Color4F}

{Number} getStartRadius()
Return starting radius of the particles. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getStartRadiusVar()
Return starting radius variance of the particles. Only available in 'Radius' mode.
Returns:
{Number}

{Number} getStartSize()
get start size in pixels of each particle
Returns:
{Number}

{Number} getStartSizeVar()
get size variance in pixels of each particle
Returns:
{Number}

{Number} getStartSpin()
get initial angle of each particle
Returns:
{Number}

{Number} getStartSpinVar()
get initial angle variance of each particle
Returns:
{Number}

{Number} getTangentialAccel()
Return tangential acceleration of each particle. Only available in 'Gravity' mode.
Returns:
{Number}

{Number} getTangentialAccelVar()
Return tangential acceleration variance of each particle. Only available in 'Gravity' mode.
Returns:
{Number}

{cc.Texture2D} getTexture()
get Texture of Particle System
Returns:
{cc.Texture2D}

{Number} getTotalParticles()
get maximum particles of the system
Returns:
{Number}

init()
initializes a cc.ParticleSystem

initParticle(particle)
Initializes a particle
Parameters:
{cc.Particle} particle

{Boolean} initWithDictionary(dictionary)
initializes a CCQuadParticleSystem from a CCDictionary.
Parameters:
{object} dictionary
Returns:
{Boolean}

{cc.ParticleSystem} initWithFile(plistFile)

initializes a CCParticleSystem from a plist file.
This plist files can be creted manually or with Particle Designer:
http://particledesigner.71squared.com/

Parameters:
{String} plistFile
Returns:
{cc.ParticleSystem}

{Boolean} initWithTotalParticles(numberOfParticles)
Initializes a system with a fixed number of particles
Parameters:
{Number} numberOfParticles
Returns:
{Boolean}

{Boolean} isActive()
Return ParticleSystem is active
Returns:
{Boolean}

{Boolean} isAutoRemoveOnFinish()

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

Returns:
{Boolean}

{Boolean} isBlendAdditive()

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;
Returns:
{Boolean}

{Boolean} isFull()
whether or not the system is full
Returns:
{Boolean}

postStep()
should be overriden by subclasses

resetSystem()
Kill all living particles.

setAngle(angle)
angle of each particle setter
Parameters:
{Number} angle

setAngleVar(angleVar)
angle variance of each particle setter
Parameters:
angleVar

setAtlasIndex(atlasIndex)
set index of system in batch node array
Parameters:
{Number} atlasIndex

setAutoRemoveOnFinish(isAutoRemoveOnFinish)

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

Parameters:
{Boolean} isAutoRemoveOnFinish

setBatchNode(batchNode)
set weak reference to the cc.SpriteBatchNode that renders the cc.Sprite
Parameters:
{cc.ParticleBatchNode} batchNode

setBlendAdditive(isBlendAdditive)

whether or not the particles are using blend additive.
If enabled, the following blending function will be used.

Parameters:
{Boolean} isBlendAdditive

setBlendFunc(src, dst)
set BlendFunc of Particle System
Parameters:
{Number} src
{Number} dst

setDrawMode(drawMode)
DrawMode of ParticleSystem setter
Parameters:
{Number} drawMode

setDuration(duration)
set run seconds of the emitter
Parameters:
{Number} duration

setEmissionRate(emissionRate)
set emission rate of the particles
Parameters:
{Number} emissionRate

setEmitterMode(emitterMode)

Switch between different kind of emitter modes:
- CCPARTICLE_MODE_GRAVITY: uses gravity, speed, radial and tangential acceleration
- CCPARTICLE_MODE_RADIUS: uses radius movement + rotation

Parameters:
{Number} emitterMode

setEndColor(endColor)
set end color and end color variation of each particle
Parameters:
{cc.Color4F} endColor

setEndColorVar(endColorVar)
set end color variance of each particle
Parameters:
{cc.Color4F} endColorVar

setEndRadius(endRadius)
ending radius of the particles setter. Only available in 'Radius' mode.
Parameters:
{Number} endRadius

setEndRadiusVar(endRadiusVar)
ending radius variance of the particles setter. Only available in 'Radius' mode.
Parameters:
endRadiusVar

setEndSize(endSize)
set end size in pixels of each particle
Parameters:
endSize

setEndSizeVar(endSizeVar)
set end size variance in pixels of each particle
Parameters:
{Number} endSizeVar

setEndSpin(endSpin)
set end angle of each particle
Parameters:
{Number} endSpin

setEndSpinVar(endSpinVar)
set end angle variance of each particle
Parameters:
{Number} endSpinVar

setGravity(gravity)
Gravity of emitter setter
Parameters:
{cc.Point} gravity

setLife(life)
life of each particle setter
Parameters:
{Number} life

setLifeVar(lifeVar)
life variance of each particle setter
Parameters:
{Number} lifeVar

setOpacityModifyRGB(newValue)
does the alpha value modify color setter
Parameters:
newValue

setParticleCount(particleCount)
Quantity of particles setter
Parameters:
{Number} particleCount

setPositionType(positionType)
set particles movement type: Free or Grouped
Parameters:
{Number} positionType

setPosVar(posVar)
Position variance of the emitter setter
Parameters:
{cc.Point} posVar

setRadialAccel(radialAccel)
radial acceleration of each particle setter. Only available in 'Gravity' mode.
Parameters:
{Number} radialAccel

setRadialAccelVar(radialAccelVar)
radial acceleration variance of each particle setter. Only available in 'Gravity' mode.
Parameters:
radialAccelVar

setRotatePerSecond(degrees)
set Number of degress to rotate a particle around the source pos per second. Only available in 'Radius' mode.
Parameters:
{Number} degrees

setRotatePerSecondVar(degrees)
Variance in degrees for rotatePerSecond setter. Only available in 'Radius' mode.
Parameters:
degrees

setRotation(newRotation)
Parameters:
newRotation

setScale(scale, scaleY)
Parameters:
scale
scaleY

setScaleX(newScaleX)
Parameters:
newScaleX

setScaleY(newScaleY)
Parameters:
newScaleY

setShapeType(shapeType)
ShapeType of ParticleSystem setter
Parameters:
{Number} shapeType

setSourcePosition(sourcePosition)
sourcePosition of the emitter setter
Parameters:
sourcePosition

setSpeed(speed)
Speed of each particle setter
Parameters:
{Number} speed

setSpeedVar(speedVar)
speed variance of each particle setter. Only available in 'Gravity' mode.
Parameters:
{Number} speedVar

setStartColor(startColor)
get start color of each particle
Parameters:
{cc.Color4F} startColor

setStartColorVar(startColorVar)
set start color variance of each particle
Parameters:
{cc.Color4F} startColorVar

setStartRadius(startRadius)
starting radius of the particles setter. Only available in 'Radius' mode.
Parameters:
{Number} startRadius

setStartRadiusVar(startRadiusVar)
starting radius variance of the particles setter. Only available in 'Radius' mode.
Parameters:
{Number} startRadiusVar

setStartSize(startSize)
set start size in pixels of each particle
Parameters:
{Number} startSize

setStartSizeVar(startSizeVar)
set size variance in pixels of each particle
Parameters:
{Number} startSizeVar

setStartSpin(startSpin)
set initial angle of each particle
Parameters:
{Number} startSpin

setStartSpinVar(startSpinVar)
set initial angle variance of each particle
Parameters:
{Number} startSpinVar

setTangentialAccel(tangentialAccel)
Tangential acceleration of each particle setter. Only available in 'Gravity' mode.
Parameters:
{Number} tangentialAccel

setTangentialAccelVar(tangentialAccelVar)
tangential acceleration variance of each particle setter. Only available in 'Gravity' mode.
Parameters:
{Number} tangentialAccelVar

setTexture(texture)
set Texture of Particle System
Parameters:
{cc.Texture2D | HTMLImageElement | HTMLCanvasElement} texture

setTotalParticles(totalParticles)
set maximum particles of the system
Parameters:
{Number} totalParticles

stopSystem()
stop emitting particles. Running particles will continue to run until they die

update(dt)
update emitter's status
Parameters:
{Number} dt
delta time

updateQuadWithParticle(particle, newPosition)
should be overriden by subclasses
Parameters:
{cc.Particle} particle
{cc.Point} newPosition

updateWithNoTime()

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:53 GMT-0800 (PST)