![]() |
cocos2d-iphone
2.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
|
#import <CCSpriteBatchNode.h>
Public Member Functions | |
(id) | - initWithTexture:capacity: |
(id) | - initWithFile:capacity: |
(void) | - increaseAtlasCapacity |
(void) | - removeChildAtIndex:cleanup: |
(void) | - removeChild:cleanup: |
(void) | - insertChild:inAtlasAtIndex: |
(void) | - appendChild: |
(void) | - removeSpriteFromAtlas: |
(NSUInteger) | - rebuildIndexInOrder:atlasIndex: |
(NSUInteger) | - atlasIndexForChild:atZ: |
(void) | - reorderBatch: |
(void) | - insertQuadFromSprite:quadIndex: |
(void) | - updateQuadFromSprite:quadIndex: |
(id) | - addSpriteWithoutQuad:z:tag: |
Static Public Member Functions | |
(id) | + batchNodeWithTexture: |
(id) | + batchNodeWithTexture:capacity: |
(id) | + batchNodeWithFile: |
(id) | + batchNodeWithFile:capacity: |
Protected Attributes | |
CCTextureAtlas * | _textureAtlas |
ccBlendFunc | _blendFunc |
CCArray * | _descendants |
Properties | |
CCTextureAtlas * | textureAtlas |
ccBlendFunc | blendFunc |
CCArray * | descendants |
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:
+ (id) batchNodeWithFile: | (NSString *) | fileImage |
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.
+ (id) batchNodeWithFile: | (NSString *) | fileImage | |
capacity: | (NSUInteger) | capacity | |
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.
+ (id) batchNodeWithTexture: | (CCTexture2D *) | tex |
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.
+ (id) batchNodeWithTexture: | (CCTexture2D *) | tex | |
capacity: | (NSUInteger) | capacity | |
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.
- (id) initWithFile: | (NSString *) | fileImage | |
capacity: | (NSUInteger) | capacity | |
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.
- (id) initWithTexture: | (CCTexture2D *) | tex | |
capacity: | (NSUInteger) | capacity | |
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.
- (void) insertQuadFromSprite: | (CCSprite *) | sprite | |
quadIndex: | (NSUInteger) | index | |
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)
- (void) removeChild: | (CCSprite *) | sprite | |
cleanup: | (BOOL) | doCleanup | |
removes a child given a reference. It will also cleanup the running actions depending on the cleanup parameter.
- (void) removeChildAtIndex: | (NSUInteger) | index | |
cleanup: | (BOOL) | doCleanup | |
removes a child given a certain index. It will also cleanup the running actions depending on the cleanup parameter.
- (void) updateQuadFromSprite: | (CCSprite *) | sprite | |
quadIndex: | (NSUInteger) | index | |
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)
- (ccBlendFunc) blendFunc [read, write, assign] |
conforms to CCTextureProtocol protocol
- (CCArray*) descendants [read, assign] |
descendants (children, grandchildren, etc)
- (CCTextureAtlas*) textureAtlas [read, write, retain] |
returns the TextureAtlas that is used