Public Member Functions | Static Public Member Functions | Properties

CCSpriteSheet Class Reference

#import <CCSpriteSheet.h>

Inherits CCNode, and CCTextureProtocol-p.

Inherited by CCBitmapFontAtlas, and CCTMXLayer.

Collaboration diagram for CCSpriteSheet:
Collaboration graph
[legend]

List of all members.

Public Member Functions

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

Static Public Member Functions

(id) + spriteSheetWithTexture:
(id) + spriteSheetWithTexture:capacity:
(id) + spriteSheetWithFile:
(id) + spriteSheetWithFile:capacity:

Properties

CCTextureAtlastextureAtlas
ccBlendFunc blendFunc
CCArray * descendants

Detailed Description

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

A CCSpriteSheet 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 CCSpriteSheet. All CCSprites added to a CCSpriteSheet are drawn in one OpenGL ES draw call. If the CCSprites are not added to a CCSpriteSheet then an OpenGL ES draw call will be needed for each one, which is less efficient.

Limitations:

Since:
v0.7.1

Definition at line 52 of file CCSpriteSheet.h.


Member Function Documentation

- (CCSprite*) createSpriteWithRect: (CGRect)  DEPRECATED_ATTRIBUTE  

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

  • create an standard CCSsprite
  • set the usingSpriteSheet = YES
  • set the textureAtlas to the same texture Atlas as the CCSpriteSheet
    Deprecated:
    Use [CCSprite spriteWithSpriteSheet: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 CCSpriteSheet. It's the same as:

  • initialize an standard CCSsprite
  • set the usingSpriteSheet = YES
  • set the textureAtlas to the same texture Atlas as the CCSpriteSheet
    Since:
    v0.99.0
    Deprecated:
    Use [CCSprite initWithSpriteSheet:rect] instead;
- (id) initWithFile: (NSString *)  fileImage
capacity: (NSUInteger)  capacity 

initializes a CCSpriteSheet 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 CCSpriteSheet 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 CCSpriteSheet 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 CCSpriteSheet is very slow
+ (id) spriteSheetWithFile: (NSString *)  fileImage  

creates a CCSpriteSheet 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) spriteSheetWithFile: (NSString *)  fileImage
capacity: (NSUInteger)  capacity 

creates a CCSpriteSheet 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) spriteSheetWithTexture: (CCTexture2D *)  tex  

creates a CCSpriteSheet 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) spriteSheetWithTexture: (CCTexture2D *)  tex
capacity: (NSUInteger)  capacity 

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


Property Documentation

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

conforms to CCTextureProtocol protocol

Definition at line 66 of file CCSpriteSheet.h.

- (CCArray*) descendants [read, assign]

descendants (children, gran children, etc)

Definition at line 69 of file CCSpriteSheet.h.

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

returns the TextureAtlas that is used

Definition at line 63 of file CCSpriteSheet.h.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines

cocos2d for iPhone 0.99.4 API Reference - Generated using Doxygen 1.7.1