Class CCSpriteBatchNode

#include <Geode/cocos/sprite_nodes/CCSpriteBatchNode.h>
classCCSpriteBatchNode:publiccocos2d::CCNode,publiccocos2d::CCTextureProtocol{ ... }

Since v0.7.1

CCSpriteBatchNode is like a batch node: if it contains children, it will draw them in 1 single OpenGL call (often known as “batch draw”).

A CCSpriteBatchNode can reference one and only one texture (one image file, one texture atlas). Only the CCSprites that are contained in that texture can be added to the CCSpriteBatchNode. All CCSprites added to a CCSpriteBatchNode 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.
Examples0
Public static methods4
staticcocos2d::CCSpriteBatchNode*createWithTexture(,
uintcapacity
)

creates a CCSpriteBatchNode with a texture2d and capacity of children. The capacity will be increased in 33% in runtime if it run out of space.

staticcocos2d::CCSpriteBatchNode*createWithTexture()
No description provided
staticcocos2d::CCSpriteBatchNode*create(
charconst*fileImage
,
uintcapacity
)

creates a CCSpriteBatchNode with a file image (.png, .jpeg, .pvr, etc) and 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.

staticcocos2d::CCSpriteBatchNode*create(
charconst*fileImage
)
No description provided
Public member functions31
cocos2d::CCTextureAtlas*getTextureAtlas()
No description provided
voidsetTextureAtlas()
No description provided
cocos2d::CCArray*getDescendants()
No description provided
boolinitWithTexture(,
uintcapacity
)

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.

boolinitWithFile(
charconst*fileImage
,
uintcapacity
)

initializes a CCSpriteBatchNode 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.

virtualboolinit()
No description provided
voidremoveChildAtIndex(
uintindex
,
booldoCleanup
)

removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.

⚠️ Removing a child from a CCSpriteBatchNode is very slow

voidinsertChild(,
uintindex
)
No description provided
voidappendChild()
No description provided
voidremoveSpriteFromAtlas()
No description provided
uintrebuildIndexInOrder(,
uintindex
)
No description provided
uinthighestAtlasIndexInChild()
No description provided
uintlowestAtlasIndexInChild()
No description provided
uintatlasIndexForChild(,)
No description provided
voidreorderBatch(
boolreorder
)
No description provided
virtualcocos2d::CCTexture2D*getTexture()
No description provided
virtualvoidsetTexture()
No description provided
virtualvoidsetBlendFunc()
No description provided
virtualcocos2d::ccBlendFuncgetBlendFunc()
No description provided
virtualvoidvisit()
No description provided
virtualvoidaddChild()
No description provided
virtualvoidaddChild(,
intzOrder
)
No description provided
virtualvoidaddChild(,
intzOrder
,
inttag
)
No description provided
virtualvoidreorderChild(,
intzOrder
)
No description provided
virtualvoidremoveChild(,
boolcleanup
)
No description provided
virtualvoidremoveAllChildrenWithCleanup(
boolcleanup
)
No description provided
virtualvoidsortAllChildren()
No description provided
virtualvoiddraw()
No description provided
intgetUsedAtlasCapacity()
No description provided
voidincreaseAtlasCapacity()
No description provided
voidincreaseAtlasCapacity()
No description provided
Fields0
Protected member functions7
voidinsertQuadFromSprite(,
uintindex
)

Inserts a quad at a certain index into the texture atlas. The CCSprite 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 CCSprite won’t be updated. For example: a tile map (CCTMXMap) or a label with lots of characters (CCLabelBMFont)

voidupdateQuadFromSprite(,
uintindex
)

Updates a quad at a certain index into the texture atlas. The CCSprite 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 CCSprite won’t be updated. For example: a tile map (CCTMXMap) or a label with lots of characters (CCLabelBMFont)

cocos2d::CCSpriteBatchNode*addSpriteWithoutQuad(,,
intaTag
)
No description provided
boolgetManualSortChildren()const
No description provided
intgetAtlasCapacity()
No description provided
voidmanualSortAllChildren()
No description provided
voidsetManualSortChildren()
No description provided
Protected fields5
cocos2d::CCTextureAtlas*m_pobTextureAtlas
;
No description provided
;
No description provided
cocos2d::CCArray*m_pobDescendants
;
No description provided
boolm_bManualSortChildren
;
No description provided
boolm_bManualSortAllChildrenDirty
;
No description provided