Public Member Functions | Static Public Member Functions | Properties

CCSpriteBatchNode Class Reference

#import "CCSpriteBatchNode.h"

Inherits CCNode, and CCTextureProtocol-p.

Inherited by CCLabelBMFont, CCSpriteSheetInternalOnly, and CCTMXLayer.

Collaboration diagram for CCSpriteBatchNode:
[legend]

List of all members.

Public Member Functions

(CCSprite *) - createSpriteWithRect:
(void) - initSprite:rect:
(id) - initWithFile:capacity:
(id) - initWithTexture:capacity:
(void) - removeChild:cleanup:
(void) - removeChildAtIndex:cleanup:

Static Public Member Functions

(id) + batchNodeWithFile:
(id) + batchNodeWithFile:capacity:
(id) + batchNodeWithTexture:
(id) + batchNodeWithTexture:capacity:

Properties

ccBlendFunc blendFunc
CCArraydescendants
CCTextureAtlastextureAtlas

Detailed Description

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:

Since:
v0.7.1

Member Function Documentation

+ (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.

- (CCSprite*) createSpriteWithRect: (CGRect)  DEPRECATED_ATTRIBUTE  

creates an sprite with a rect in the CCSpriteBatchNode. It's the same as:

  • create an standard CCSsprite
  • set the usingSpriteSheet = YES
  • set the textureAtlas to the same texture Atlas as the CCSpriteBatchNode
    Deprecated:
    Use [CCSprite spriteWithBatchNode:rect:] instead;
- (void) initSprite: (CCSprite *)  sprite
rect: (CGRect)  DEPRECATED_ATTRIBUTE 

initializes a previously created sprite with a rect. This sprite will have the same texture as the CCSpriteBatchNode. It's the same as:

  • initialize an standard CCSsprite
  • set the usingBatchNode = YES
  • set the textureAtlas to the same texture Atlas as the CCSpriteBatchNode
    Since:
    v0.99.0
    Deprecated:
    Use [CCSprite initWithBatchNode:rect:] instead;
- (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) removeChild: (CCSprite *)  sprite
cleanup: (BOOL)  doCleanup 

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

Warning:
Removing a child from a CCSpriteBatchNode is very slow
- (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.

Warning:
Removing a child from a CCSpriteBatchNode is very slow

Property Documentation

- (ccBlendFunc) blendFunc [read, write, assign]

conforms to CCTextureProtocol protocol

- (CCArray*) descendants [read, assign]

descendants (children, gran children, etc)

- (CCTextureAtlas*) textureAtlas [read, write, retain]

returns the TextureAtlas that is used


The documentation for this class was generated from the following file: