cocos2d-iphone  1.1
Improved Cocos2D API Reference (iOS version) for www.kobold2d.com developers
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Properties Defines
CCTextureAtlas Class Reference

#import <CCTextureAtlas.h>

Collaboration diagram for CCTextureAtlas:

List of all members.

Public Member Functions

(id) - initWithFile:capacity:
(id) - initWithTexture:capacity:
(void) - updateQuad:atIndex:
(void) - insertQuad:atIndex:
(void) - insertQuads:atIndex:amount:
(void) - insertQuadFromIndex:atIndex:
(void) - insertQuadsFromIndex:amount:atIndex:
(void) - removeQuadAtIndex:
(void) - removeQuadsAtIndex:amount:
(void) - removeAllQuads
(BOOL) - resizeCapacity:
(void) - increaseTotalQuadsWith:
(void) - moveQuadsFromIndex:to:
(void) - fillWithEmptyQuadsFromIndex:amount:
(void) - drawNumberOfQuads:
(void) - drawNumberOfQuads:fromIndex:
(void) - drawQuads

Static Public Member Functions

(id) + textureAtlasWithFile:capacity:
(id) + textureAtlasWithTexture:capacity:

Protected Attributes

NSUInteger totalQuads_
NSUInteger capacity_
ccV3F_C4B_T2F_Quadquads_
GLushort * indices_
CCTexture2Dtexture_

Properties

NSUInteger totalQuads
NSUInteger capacity
CCTexture2Dtexture
ccV3F_C4B_T2F_Quadquads

Detailed Description

A class that implements a Texture Atlas. Supported features: The atlas file can be a PVRTC, PNG or any other fomrat supported by Texture2D Quads can be udpated in runtime Quads can be added in runtime Quads can be removed in runtime Quads can be re-ordered in runtime The TextureAtlas capacity can be increased or decreased in runtime OpenGL component: V3F, C4B, T2F. The quads are rendered using an OpenGL ES VBO. To render the quads using an interleaved vertex array list, you should modify the ccConfig.h file


Member Function Documentation

- (void) drawNumberOfQuads: (NSUInteger)  n

draws n quads n can't be greater than the capacity of the Atlas

- (void) drawNumberOfQuads: (NSUInteger)  n
fromIndex: (NSUInteger)  start 

draws n quads from an index (offset). n + start can't be greater than the capacity of the atlas

Since:
v1.0
- (void) drawQuads

draws all the Atlas's Quads

- (void) fillWithEmptyQuadsFromIndex: (NSUInteger)  index
amount: (NSUInteger)  amount 

Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode

Since:
1.1
- (void) increaseTotalQuadsWith: (NSUInteger)  amount

Used internally by CCParticleBatchNode don't use this unless you know what you're doing

Since:
1.1
- (id) initWithFile: (NSString *)  file
capacity: (NSUInteger)  capacity 

initializes a TextureAtlas with a filename and with a certain capacity for Quads. The TextureAtlas capacity can be increased in runtime.

WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)

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

initializes a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for Quads. The TextureAtlas capacity can be increased in runtime.

WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)

- (void) insertQuad: (ccV3F_C4B_T2F_Quad *)  quad
atIndex: (NSUInteger)  index 

Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1

Since:
v0.8
- (void) insertQuadFromIndex: (NSUInteger)  fromIndex
atIndex: (NSUInteger)  newIndex 

Removes the quad that is located at a certain index and inserts it at a new index This operation is faster than removing and inserting in a quad in 2 different steps

Since:
v0.7.2
- (void) insertQuads: (ccV3F_C4B_T2F_Quad *)  quads
atIndex: (NSUInteger)  index
amount: (NSUInteger)  amount 

Inserts a c array of quads at a given index index must be between 0 and the atlas capacity - 1 this method doesn't enlarge the array when amount + index > totalQuads

Since:
v1.1
- (void) insertQuadsFromIndex: (NSUInteger)  oldIndex
amount: (NSUInteger)  amount
atIndex: (NSUInteger)  newIndex 

Inserts a amount of quads from oldIndex at newIndex, while moving quads at newIndex - oldIndex back accordingly

Since:
v1.1
- (void) moveQuadsFromIndex: (NSUInteger)  index
to: (NSUInteger)  newIndex 

Moves quads from index till totalQuads to the newIndex Used internally by CCParticleBatchNode This method doesn't enlarge the array if newIndex + quads to be moved > capacity

Since:
1.1
- (void) removeAllQuads

removes all Quads. The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0

Since:
v0.7.2
- (void) removeQuadAtIndex: (NSUInteger)  index

removes a quad at a given index number. The capacity remains the same, but the total number of quads to be drawn is reduced in 1

Since:
v0.7.2
- (void) removeQuadsAtIndex: (NSUInteger)  index
amount: (NSUInteger)  amount 

removes a amount of quads starting from index

Since:
1.1
- (BOOL) resizeCapacity: (NSUInteger)  n

resize the capacity of the CCTextureAtlas. The new capacity can be lower or higher than the current one It returns YES if the resize was successful. If it fails to resize the capacity it will return NO with a new capacity of 0.

+ (id) textureAtlasWithFile: (NSString *)  file
capacity: (NSUInteger)  capacity 

creates a TextureAtlas with an filename and with an initial capacity for Quads. The TextureAtlas capacity can be increased in runtime.

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

creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads. The TextureAtlas capacity can be increased in runtime.

- (void) updateQuad: (ccV3F_C4B_T2F_Quad *)  quad
atIndex: (NSUInteger)  index 

updates a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity - 1

Since:
v0.8

Property Documentation

- (NSUInteger) capacity [read, assign]

quantity of quads that can be stored with the current texture atlas size

- (ccV3F_C4B_T2F_Quad*) quads [read, write, assign]

Quads that are going to be rendered

- (CCTexture2D*) texture [read, write, retain]

Texture of the texture atlas

- (NSUInteger) totalQuads [read, assign]

quantity of quads that are going to be drawn


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