Inherits from CCNode : NSObject
Conforms to CCTextureProtocol
Declared in CCSpriteSheet.h

Overview

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: – 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 CCSpriteSheet. – 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.

Tasks

  •   textureAtlas

    returns the TextureAtlas that is used

    property
  •   blendFunc

    conforms to CCTextureProtocol protocol

    property
  •   descendants

    descendants (children, gran children, etc)

    property
  • + spriteSheetWithTexture:

    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.

  • + spriteSheetWithTexture: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.

  • + spriteSheetWithFile:

    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.

  • + spriteSheetWithFile: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.

  • – initWithTexture: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.

  • – initWithFile: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.

  • – increaseAtlasCapacity
  • – createSpriteWithRect:

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

  • – initSprite:rect:

    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 (Deprecated: Use [CCSprite initWithSpriteSheet:rect] instead;)

  • – removeChildAtIndex:cleanup:

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

  • – removeChild:cleanup:

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

  • – insertChild:inAtlasAtIndex:
  • – removeSpriteFromAtlas:
  • – rebuildIndexInOrder:atlasIndex:
  • – atlasIndexForChild:atZ:

Properties

blendFunc

conforms to CCTextureProtocol protocol

@property (nonatomic, readwrite) ccBlendFunc blendFunc

Declared In

CCSpriteSheet.h

descendants

descendants (children, gran children, etc)

@property (nonatomic, readonly) CCArray *descendants

Declared In

CCSpriteSheet.h

textureAtlas

returns the TextureAtlas that is used

@property (nonatomic, readwrite, retain) CCTextureAtlas *textureAtlas

Declared In

CCSpriteSheet.h

Class Methods

spriteSheetWithFile:

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

Declared In

CCSpriteSheet.h

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

Declared In

CCSpriteSheet.h

spriteSheetWithTexture:

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

Declared In

CCSpriteSheet.h

spriteSheetWithTexture: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.

+ (id)spriteSheetWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity

Declared In

CCSpriteSheet.h

Instance Methods

atlasIndexForChild:atZ:

createSpriteWithRect:

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

- (CCSprite *)createSpriteWithRect:(CGRect)rect

Declared In

CCSpriteSheet.h

increaseAtlasCapacity

initSprite:rect:

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 (Deprecated: Use [CCSprite initWithSpriteSheet:rect] instead;)

- (void)initSprite:(CCSprite *)sprite rect:(CGRect)rect

Availability

Declared In

CCSpriteSheet.h

initWithFile: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)initWithFile:(NSString *)fileImage capacity:(NSUInteger)capacity

Declared In

CCSpriteSheet.h

initWithTexture: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.

- (id)initWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity

Declared In

CCSpriteSheet.h

insertChild:inAtlasAtIndex:

rebuildIndexInOrder:atlasIndex:

removeChild:cleanup:

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

- (void)removeChild:(CCSprite *)sprite cleanup:(BOOL)doCleanup

Discussion

Warning: Removing a child from a CCSpriteSheet is very slow

Declared In

CCSpriteSheet.h

removeChildAtIndex:cleanup:

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

- (void)removeChildAtIndex:(NSUInteger)index cleanup:(BOOL)doCleanup

Discussion

Warning: Removing a child from a CCSpriteSheet is very slow

Declared In

CCSpriteSheet.h

removeSpriteFromAtlas: