Class cc.SpriteBatchNode
Extends
cc.Node.
Defined in: CCSpriteBatchNode.js.
Constructor Attributes | Constructor Name and Description |
---|---|
In WebGL render mode ,cc.SpriteBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call |
Method Attributes | Method Name and Description |
---|---|
addChild(child, zOrder, tag)
add child to cc.SpriteBatchNode (override addChild of cc.Node)
|
|
addQuadFromSprite(sprite, index)
Adds a quad into the texture atlas but it won't be added into the children array. |
|
addSpriteWithoutQuad(child, z, aTag)
This is the opposite of "addQuadFromSprite. |
|
appendChild(sprite)
addChild helper, faster than insertChild
|
|
atlasIndexForChild(sprite, nZ)
get atlas index for child
|
|
<static> |
cc.SpriteBatchNode.create(fileImage, capacity)
creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children. |
<static> |
cc.SpriteBatchNode.createWithTexture(texture, capacity)
creates a CCSpriteBatchNode with a texture2d and a default capacity of 29 children. |
ctor(fileImage)
Constructor
|
|
draw(ctx)
draw cc.SpriteBatchNode (override draw of cc.Node)
|
|
returns the blending function used for the texture
|
|
Return Descendants of cc.SpriteBatchNode
|
|
Return texture of cc.SpriteBatchNode
|
|
Return TextureAtlas of cc.SpriteBatchNode
|
|
highestAtlasIndexInChild(sprite)
get highest atlas index in child
|
|
increase Atlas Capacity
|
|
init(fileImage, capacity)
initializes a cc.SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children. |
|
initWithTexture(tex, capacity)
initializes a CCSpriteBatchNode with a texture2d and capacity of children. |
|
insertChild(sprite, index)
add child helper
|
|
lowestAtlasIndexInChild(sprite)
get lowest atlas index in child
|
|
rebuildIndexInOrder(pobParent, index)
rebuild index in order for child
|
|
removeAllChildren(cleanup)
Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter. |
|
removeChild(child, cleanup)
remove child from cc.SpriteBatchNode (override removeChild of cc.Node)
|
|
removeChildAtIndex(index, doCleanup)
removes a child given a certain index.
|
|
removeSpriteFromAtlas(sprite)
remove sprite from TextureAtlas
|
|
reorderBatch(reorder)
Sprites use this to start sortChildren, don't call this manually
|
|
reorderChild(child, zOrder)
(override reorderChild of cc.Node)
|
|
setBlendFunc(src, dst)
set the source blending function for the texture
|
|
setContentSize(size)
|
|
set this node is dirty ,need redraw
|
|
setTexture(texture)
texture of cc.SpriteBatchNode setter
|
|
setTextureAtlas(textureAtlas)
TextureAtlas of cc.SpriteBatchNode setter
|
|
visit(ctx)
don't call visit on it's children ( override visit of cc.Node )
|
- Methods borrowed from class cc.Node:
- cleanup, convertToNodeSpace, convertToNodeSpaceAR, convertTouchToNodeSpace, convertTouchToNodeSpaceAR, convertToWorldSpace, convertToWorldSpaceAR, description, getActionByTag, getActionManager, getAnchorPoint, getAnchorPointInPoints, getBoundingBox, getBoundingBoxToWorld, 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, removeAllChildrenWithCleanup, removeChildByTag, removeFromParent, removeFromParentAndCleanup, resumeSchedulerAndActions, retain, runAction, schedule, scheduleOnce, scheduleUpdate, scheduleUpdateWithPriority, setActionManager, setAnchorPoint, setGLServerState, setGrid, setOrderOfArrival, setParent, setPosition, setPositionX, setPositionY, setRotation, setScale, setScaleX, setScaleY, setScheduler, setShaderProgram, setSkewX, setSkewY, setTag, setUserData, setUserObject, setVertexZ, setVisible, setZOrder, stopAction, stopActionByTag, stopAllActions, transform, transformAncestors, unschedule, unscheduleAllCallbacks, unscheduleUpdate, update, updateTransform, worldToNodeTransform
In WebGL render mode ,cc.SpriteBatchNode 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.SpriteBatchNode can reference one and only one texture (one image file, one texture atlas).
Only the cc.Sprites that are contained in that texture can be added to the cc.SpriteBatchNode.
All cc.Sprites added to a cc.SpriteBatchNode are drawn in one OpenGL ES draw call.
If the CCSprites are not added to a CCSpriteBatchNode then an OpenGL ES draw call will be needed for each one, which is less efficient.
Limitations:
- The only object that is accepted as child (or grandchild, grand-grandchild, etc...) is CCSprite or any subclass of CCSprite.
eg: particles, labels and layer can't be added to a CCSpriteBatchNode.
- Either all its children are Aliased or Antialiased. It can't be a mix.
This is because "alias" is a property of the texture, and all the sprites share the same texture.
//create a SpriteBatchNode var parent2 = cc.SpriteBatchNode.create("res/animations/grossini.png", 50);
- Parameters:
- {cc.Sprite} child
- {Number} zOrder
- {Number} tag
Adds a quad into the texture atlas but it won't be added into the children array.
This method should be called only when you are dealing with very big AtlasSrite and when most of the cc.Sprite won't be updated.
For example: a tile map (cc.TMXMap) or a label with lots of characters (BitmapFontAtlas)
- Parameters:
- {cc.Sprite} sprite
- {Number} index
This is the opposite of "addQuadFromSprite.
It add the sprite to the children and descendants array, but it doesn't update add it to the texture atlas
- Parameters:
- {cc.Node} child
- {Number} z
- zOrder
- {Number} aTag
- Returns:
- {cc.SpriteBatchNode}
- Parameters:
- {cc.Sprite} sprite
- Parameters:
- {cc.Sprite} sprite
- {Number} nZ
- Returns:
- {Number}
creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) with a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
//create a SpriteBatchNode var parent2 = cc.SpriteBatchNode.create("res/animations/grossini.png", 50);
- Parameters:
- {String} fileImage
- {Number} capacity
- Returns:
- {cc.SpriteBatchNode}
creates a CCSpriteBatchNode with a texture2d and a default capacity of 29 children.
The capacity will be increased in 33% in runtime if it run out of space.
- Parameters:
- {cc.Texture2D} texture
- {Number} capacity
- Returns:
- {cc.SpriteBatchNode}
- Parameters:
- {String} fileImage
- Parameters:
- {CanvasContext} ctx
- Returns:
- {cc.BlendFunc}
- Returns:
- {Array}
- Returns:
- {cc.Texture2D}
- Returns:
- {cc.TextureAtlas}
- Parameters:
- {cc.Sprite} sprite
- Returns:
- {Number}
initializes a cc.SpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and a capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
The file will be loaded using the TextureMgr.
- Parameters:
- {String} fileImage
- {Number} capacity
- Returns:
- {Boolean}
initializes a CCSpriteBatchNode with a texture2d and capacity of children.
The capacity will be increased in 33% in runtime if it run out of space.
- Parameters:
- {cc.Texture2D} tex
- {Number} capacity
- Returns:
- {Boolean}
- Parameters:
- {cc.Sprite} sprite
- {Number} index
- Parameters:
- {cc.Sprite} sprite
- Returns:
- {Number}
- Parameters:
- {cc.Sprite} pobParent
- {Number} index
- Returns:
- {Number}
Removes all children from the container and do a cleanup all running actions depending on the cleanup parameter.
(override removeAllChildren of cc.Node)
- Parameters:
- {Boolean} cleanup
- Parameters:
- {cc.Sprite} child
- cleanup
- Parameters:
- {Number} index
- {Boolean} doCleanup
- Parameters:
- {cc.Sprite} sprite
- Parameters:
- {Boolean} reorder
- Parameters:
- {cc.Sprite} child
- {Number} zOrder
- Parameters:
- {Number} src
- {Number} dst
- Parameters:
- size
- Parameters:
- {cc.Texture2D} texture
- Parameters:
- {cc.TextureAtlas} textureAtlas
- Parameters:
- {CanvasContext} ctx