Class cc.ParticleSystem
Extends
cc.Node.
Defined in: CCParticleSystem.js.
Constructor Attributes | Constructor Name and Description |
---|---|
Particle System base class. |
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
|
|
getAngle()
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
|
|
getLife()
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
|
|
getSpeed()
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
|
|
isActive()
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. |
|
isFull()
whether or not the system is full
|
|
postStep()
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: |
|
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
|
|
setOpacityModifyRGB(newValue)
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.
|
|
setRotatePerSecond(degrees)
set Number of degress to rotate a particle around the source pos per second.
|
|
setRotatePerSecondVar(degrees)
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
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;
- Returns:
- {Boolean}
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}
- Parameters:
- number_of_particles
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.ParticleBatchNode}
- Returns:
- {cc.BlendFunc}
- Returns:
- {cc.Rect}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Color4F}
- Returns:
- {cc.Color4F}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Point}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Boolean}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Point}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Point}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Color4F}
- Returns:
- {cc.Color4F}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {Number}
- Returns:
- {cc.Texture2D}
- Returns:
- {Number}
- Parameters:
- {cc.Particle} particle
- Parameters:
- {object} dictionary
- Returns:
- {Boolean}
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}
- Parameters:
- {Number} numberOfParticles
- Returns:
- {Boolean}
- Returns:
- {Boolean}
return whether or not the node will be auto-removed when it has no particles left.
By default it is false.
- Returns:
- {Boolean}
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}
- Returns:
- {Boolean}
- Parameters:
- {Number} angle
- Parameters:
- angleVar
- Parameters:
- {Number} atlasIndex
set whether or not the node will be auto-removed when it has no particles left.
By default it is false.
- Parameters:
- {Boolean} isAutoRemoveOnFinish
- Parameters:
- {cc.ParticleBatchNode} batchNode
whether or not the particles are using blend additive.
If enabled, the following blending function will be used.
- Parameters:
- {Boolean} isBlendAdditive
- Parameters:
- {Number} src
- {Number} dst
- Parameters:
- {Number} drawMode
- Parameters:
- {Number} duration
- Parameters:
- {Number} emissionRate
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
- Parameters:
- {cc.Color4F} endColor
- Parameters:
- {cc.Color4F} endColorVar
- Parameters:
- {Number} endRadius
- Parameters:
- endRadiusVar
- Parameters:
- endSize
- Parameters:
- {Number} endSizeVar
- Parameters:
- {Number} endSpin
- Parameters:
- {Number} endSpinVar
- Parameters:
- {cc.Point} gravity
- Parameters:
- {Number} life
- Parameters:
- {Number} lifeVar
- Parameters:
- newValue
- Parameters:
- {Number} particleCount
- Parameters:
- {Number} positionType
- Parameters:
- {cc.Point} posVar
- Parameters:
- {Number} radialAccel
- Parameters:
- radialAccelVar
- Parameters:
- {Number} degrees
- Parameters:
- degrees
- Parameters:
- newRotation
- Parameters:
- scale
- scaleY
- Parameters:
- newScaleX
- Parameters:
- newScaleY
- Parameters:
- {Number} shapeType
- Parameters:
- sourcePosition
- Parameters:
- {Number} speed
- Parameters:
- {Number} speedVar
- Parameters:
- {cc.Color4F} startColor
- Parameters:
- {cc.Color4F} startColorVar
- Parameters:
- {Number} startRadius
- Parameters:
- {Number} startRadiusVar
- Parameters:
- {Number} startSize
- Parameters:
- {Number} startSizeVar
- Parameters:
- {Number} startSpin
- Parameters:
- {Number} startSpinVar
- Parameters:
- {Number} tangentialAccel
- Parameters:
- {Number} tangentialAccelVar
- Parameters:
- {cc.Texture2D | HTMLImageElement | HTMLCanvasElement} texture
- Parameters:
- {Number} totalParticles
- Parameters:
- {Number} dt
- delta time
- Parameters:
- {cc.Particle} particle
- {cc.Point} newPosition