cocos2d-iphone  2.1
Improved Cocos2D API Reference (iOS version) for www.koboldtouch.com developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Pages
CCSpriteBatchNode Class Reference

#import <CCSpriteBatchNode.h>

Inheritance diagram for CCSpriteBatchNode:
Collaboration diagram for CCSpriteBatchNode:

Instance Methods

(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:
 
 Instance Methods inherited from CCNode
(id) - init
 
(void) - onEnter
 
(void) - onEnterTransitionDidFinish
 
(void) - onExit
 
(void) - onExitTransitionDidStart
 
(void) - addChild:
 
(void) - addChild:z:
 
(void) - addChild:z:tag:
 
(void) - removeFromParent
 
(void) - removeFromParentAndCleanup:
 
(void) - removeChild:
 
(void) - removeChild:cleanup:
 
(void) - removeChildByTag:
 
(void) - removeChildByTag:cleanup:
 
(void) - removeAllChildren
 
(void) - removeAllChildrenWithCleanup:
 
(CCNode *) - getChildByTag:
 
(void) - reorderChild:z:
 
(void) - sortAllChildren
 
(void) - cleanup
 
(void) - draw
 
(void) - visit
 
(void) - transform
 
(void) - transformAncestors
 
(CGRect) - boundingBox
 
(CCAction *) - runAction:
 
(void) - stopAllActions
 
(void) - stopAction:
 
(void) - stopActionByTag:
 
(CCAction *) - getActionByTag:
 
(NSUInteger) - numberOfRunningActions
 
(void) - scheduleUpdate
 
(void) - scheduleUpdateWithPriority:
 
(void) - unscheduleUpdate
 
(void) - schedule:
 
(void) - schedule:interval:
 
(void) - schedule:interval:repeat:delay:
 
(void) - scheduleOnce:delay:
 
(void) - unschedule:
 
(void) - unscheduleAllSelectors
 
(void) - resumeSchedulerAndActions
 
(void) - pauseSchedulerAndActions
 
(void) - update:
 
(CGAffineTransform) - nodeToParentTransform
 
(CGAffineTransform) - parentToNodeTransform
 
(CGAffineTransform) - nodeToWorldTransform
 
(CGAffineTransform) - worldToNodeTransform
 
(CGPoint) - convertToNodeSpace:
 
(CGPoint) - convertToWorldSpace:
 
(CGPoint) - convertToNodeSpaceAR:
 
(CGPoint) - convertToWorldSpaceAR:
 
(CGPoint) - convertTouchToNodeSpace:
 
(CGPoint) - convertTouchToNodeSpaceAR:
 
(void) - setIsRelativeAnchorPoint:
 
(BOOL) - DEPRECATED_ATTRIBUTE
 
(void) - setZOrder:
 
 Instance Methods inherited from <CCTextureProtocol>
(CCTexture2D *) - texture
 
(void) - setTexture:
 
 Instance Methods inherited from <CCBlendProtocol>
(void) - setBlendFunc:
 
(ccBlendFunc- blendFunc
 

Class Methods

(id) + batchNodeWithTexture:
 
(id) + batchNodeWithTexture:capacity:
 
(id) + batchNodeWithFile:
 
(id) + batchNodeWithFile:capacity:
 
 Class Methods inherited from CCNode
(id) + node
 

Protected Attributes

CCTextureAtlas_textureAtlas
 
ccBlendFunc _blendFunc
 
CCArray_descendants
 
 Protected Attributes inherited from CCNode
float _rotationX
 
float _rotationY
 
float _scaleX
 
float _scaleY
 
float _vertexZ
 
CGPoint _position
 
float _skewX
 
float _skewY
 
CGPoint _anchorPointInPoints
 
CGPoint _anchorPoint
 
CGSize _contentSize
 
CGAffineTransform _transform
 
CGAffineTransform _inverse
 
BOOL _isTransformDirty
 
BOOL _isInverseDirty
 
CCCamera_camera
 
CCGridBase_grid
 
NSInteger _zOrder
 
CCArray_children
 
CCNode_parent
 
NSInteger _tag
 
void * _userData
 
id _userObject
 
CCGLProgram_shaderProgram
 
ccGLServerState _glServerState
 
NSUInteger _orderOfArrival
 
CCScheduler_scheduler
 
CCActionManager_actionManager
 
BOOL _isRunning
 
BOOL _visible
 
BOOL _ignoreAnchorPointForPosition
 
BOOL _isReorderChildDirty
 

Properties

CCTextureAtlastextureAtlas
 
ccBlendFunc blendFunc
 
CCArraydescendants
 
 Properties inherited from CCNode
NSInteger zOrder
 
float vertexZ
 
float skewX
 
float skewY
 
float rotation
 
float rotationX
 
float rotationY
 
float scale
 
float scaleX
 
float scaleY
 
CGPoint position
 
CCCameracamera
 
CCArraychildren
 
CCGridBasegrid
 
BOOL visible
 
CGPoint anchorPoint
 
CGPoint anchorPointInPoints
 
CGSize contentSize
 
BOOL isRunning
 
CCNodeparent
 
BOOL ignoreAnchorPointForPosition
 
NSInteger tag
 
void * userData
 
id userObject
 
CCGLProgramshaderProgram
 
NSUInteger orderOfArrival
 
ccGLServerState glServerState
 
CCActionManageractionManager
 
CCSchedulerscheduler
 

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:

  • 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.
Since
v0.7.1

Method 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.

- (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)

Provided by category CCSpriteBatchNode(QuadExtensions).

- (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
- (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)

Provided by category CCSpriteBatchNode(QuadExtensions).

Property Documentation

- (ccBlendFunc) blendFunc
readwritenonatomicassign

conforms to CCTextureProtocol protocol

- (CCArray*) descendants
readnonatomicassign

descendants (children, grandchildren, etc)

- (CCTextureAtlas*) textureAtlas
readwritenonatomicretain

returns the TextureAtlas that is used


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