Class cc.ParticleBatchNode

Class Summary
Constructor Attributes Constructor Name and Description
 
cc.ParticleBatchNode(fileImage, capacity)

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").

Method Summary

Class Detail

cc.ParticleBatchNode(fileImage, capacity)

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

1.
//Create a cc.ParticleBatchNode with image path  and capacity
var particleBatchNode = new cc.ParticleBatchNode("res/grossini_dance.png",30);

2.
//Create a cc.ParticleBatchNode with a texture and capacity
var texture = cc.TextureCache.getInstance().addImage("res/grossini_dance.png");
var particleBatchNode = new cc.ParticleBatchNode(texture, 30);
Parameters:
{String|cc.Texture2D} fileImage
{Number} capacity

Field Detail

{cc.Texture2D|HTMLImageElement|HTMLCanvasElement} texture
- The used texture
{cc.TextureAtlas} textureAtlas
- The texture atlas used for drawing the quads

Method Detail

  • addChild(child, zOrder, tag)
    Add a child into the cc.ParticleBatchNode
    Parameters:
    {cc.ParticleSystem} child
    {Number} zOrder
    {Number} tag
  • <static> {cc.ParticleBatchNode} cc.ParticleBatchNode.create(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|cc.Texture2D} fileImage
    {Number} capacity
    Deprecated:
    since v3.0 please use new cc.ParticleBatchNode(filename, capacity) instead.
    Returns:
    {cc.ParticleBatchNode}
  • ctor(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 Constructor of cc.ParticleBatchNode
    1.
    //Create a cc.ParticleBatchNode with image path  and capacity
    var particleBatchNode = new cc.ParticleBatchNode("res/grossini_dance.png",30);
    
    2.
    //Create a cc.ParticleBatchNode with a texture and capacity
    var texture = cc.TextureCache.getInstance().addImage("res/grossini_dance.png");
    var particleBatchNode = new cc.ParticleBatchNode(texture, 30);
    Parameters:
    {String|cc.Texture2D} fileImage
    {Number} capacity
  • disableParticle(particleIndex)
    disables a particle by inserting a 0'd quad into the texture atlas
    Parameters:
    {Number} particleIndex
  • {cc.BlendFunc} getBlendFunc()
    returns the blending function used for the texture
    Returns:
    {cc.BlendFunc}
  • {cc.Texture2D} getTexture()
    returns the used texture
    Returns:
    {cc.Texture2D}
  • {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|Object} src
    {Number} dst
  • setTexture(texture)
    sets a new texture. it will be retained
    Parameters:
    {cc.Texture2D} texture
  • setTextureAtlas(textureAtlas)
    set the texture atlas used for drawing the quads
    Parameters:
    {cc.TextureAtlas} textureAtlas