Class cc.ParticleBatchNode
- Defined in: CCParticleBatchNode.js
- Extends cc.ParticleSystem
Constructor Attributes | Constructor Name and Description |
---|---|
cc.ParticleBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call |
Method Summary
Class Detail
cc.ParticleBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call
(often known as "batch draw").
A cc.ParticleBatchNode can reference one and only one texture (one image file, one texture atlas).
Only the cc.ParticleSystems that are contained in that texture can be added to the cc.SpriteBatchNode.
All cc.ParticleSystems added to a cc.SpriteBatchNode are drawn in one OpenGL ES draw call.
If the cc.ParticleSystems are not added to a cc.ParticleBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient.
Limitations:
- At the moment only cc.ParticleSystem is supported
- All systems need to be drawn with the same parameters, blend function, aliasing, texture
Most efficient usage
- Initialize the ParticleBatchNode with the texture and enough capacity for all the particle systems
- Initialize all particle systems and add them as child to the batch node
Method Detail
-
addChild(child, zOrder, tag)Add a child into the cc.ParticleBatchNode
- Parameters:
- {cc.ParticleSystem} child
- {Number} zOrder
- {Number} tag
-
initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles
- Parameters:
- {String} fileImage
- capacity
- Returns:
- {cc.ParticleBatchNode}
-
initializes the particle system with cc.Texture2D, a capacity of particles, which particle system to use
- Parameters:
- {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture
- {Number} capacity
- Returns:
- {cc.ParticleBatchNode}
-
disableParticle(particleIndex)disables a particle by inserting a 0'd quad into the texture atlas
- Parameters:
- {Number} particleIndex
-
draw(ctx)
- Parameters:
- {CanvasContext} ctx
-
{cc.BlendFunc} getBlendFunc()returns the blending function used for the texture
- Returns:
- {cc.BlendFunc}
-
{cc.Texture2D|HTMLImageElement|HTMLCanvasElement} getTexture()returns the used texture
- Returns:
- {cc.Texture2D|HTMLImageElement|HTMLCanvasElement}
-
{cc.TextureAtlas} getTextureAtlas()return the texture atlas used for drawing the quads
- Returns:
- {cc.TextureAtlas}
-
{Boolean} init(fileImage, capacity)initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles
- Parameters:
- {String} fileImage
- {Number} capacity
- Returns:
- {Boolean}
-
{Boolean} initWithFile(fileImage, capacity)initializes the particle system with the name of a file on disk (for a list of supported formats look at the cc.Texture2D class), a capacity of particles
- Parameters:
- {String} fileImage
- {Number} capacity
- Returns:
- {Boolean}
-
{Boolean} initWithTexture(texture, capacity)initializes the particle system with cc.Texture2D, a capacity of particles
- Parameters:
- {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture
- {Number} capacity
- Returns:
- {Boolean}
-
insertChild(pSystem, index)Inserts a child into the cc.ParticleBatchNode
- Parameters:
- {cc.ParticleSystem} pSystem
- {Number} index
-
removeAllChildren(doCleanup)
- Parameters:
- {Boolean} doCleanup
-
removeChild(child, cleanup)
- Parameters:
- {cc.ParticleSystem} child
- {Boolean} cleanup
-
removeChildAtIndex(index, doCleanup)
- Parameters:
- {Number} index
- {Boolean} doCleanup
-
reorderChild(child, zOrder)Reorder will be done in this function, no "lazy" reorder to particles
- Parameters:
- {cc.ParticleSystem} child
- {Number} zOrder
-
setBlendFunc(src, dst)set the blending function used for the texture
- Parameters:
- {Number} src
- {Number} dst
-
setTexture(texture)sets a new texture. it will be retained
- Parameters:
- {cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture
-
setTextureAtlas(textureAtlas)set the texture atlas used for drawing the quads
- Parameters:
- {cc.TextureAtlas} textureAtlas