CCTextureAtlas Class Reference
Inherits from | NSObject |
Declared in | CCTextureAtlas.h |
Overview
A class that implements a Texture Atlas. Supported features: * The atlas file can be a PVRTC, PNG or any other format supported by Texture2D * Quads can be updated 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
Tasks
-
totalQuads
quantity of quads that are going to be drawn
property -
capacity
quantity of quads that can be stored with the current texture atlas size
property -
texture
Texture of the texture atlas
property -
quads
Quads that are going to be rendered
property -
+ textureAtlasWithFile:capacity:
creates a TextureAtlas with an filename and with an initial capacity for Quads. The TextureAtlas capacity can be increased in runtime.
-
– initWithFile:capacity:
initializes a TextureAtlas with a filename and with a certain capacity for Quads. The TextureAtlas capacity can be increased in runtime.
-
+ textureAtlasWithTexture: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.
-
– initWithTexture: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.
-
– updateQuad:atIndex:
updates a Quad (texture, vertex and color) at a certain index * index must be between 0 and the atlas capacity – 1
-
– insertQuad:atIndex:
Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity – 1
-
– insertQuads:atIndex: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
-
– insertQuadFromIndex:atIndex:
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
-
– removeQuadAtIndex:
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
-
– removeQuadsAtIndex:amount:
removes a amount of quads starting from index
-
– removeAllQuads
removes all Quads. The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0
-
– resizeCapacity:
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.
-
– increaseTotalQuadsWith:
Used internally by CCParticleBatchNode don’t use this unless you know what you’re doing
-
– moveQuadsFromIndex:amount:atIndex:
Moves an amount of quads from oldIndex at newIndex
-
– moveQuadsFromIndex:to:
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
-
– fillWithEmptyQuadsFromIndex:amount:
Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode
-
– drawNumberOfQuads:
draws n quads n can’t be greater than the capacity of the Atlas
-
– drawNumberOfQuads:fromIndex:
draws n quads from an index (offset). n + start can’t be greater than the capacity of the atlas
-
– drawQuads
draws all the Atlas’s Quads
Properties
capacity
quantity of quads that can be stored with the current texture atlas size
@property (nonatomic, readonly) NSUInteger capacity
Declared In
CCTextureAtlas.h
quads
Quads that are going to be rendered
@property (nonatomic, readwrite) ccV3F_C4B_T2F_Quad *quads
Declared In
CCTextureAtlas.h
Class Methods
textureAtlasWithFile:capacity:
creates a TextureAtlas with an filename and with an initial capacity for Quads. The TextureAtlas capacity can be increased in runtime.
+ (id)textureAtlasWithFile:(NSString *)file capacity:(NSUInteger)capacity
Declared In
CCTextureAtlas.h
textureAtlasWithTexture: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.
+ (id)textureAtlasWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity
Declared In
CCTextureAtlas.h
Instance Methods
drawNumberOfQuads:
draws n quads n can’t be greater than the capacity of the Atlas
- (void)drawNumberOfQuads:(NSUInteger)n
Declared In
CCTextureAtlas.h
drawNumberOfQuads:fromIndex:
draws n quads from an index (offset). n + start can’t be greater than the capacity of the atlas
- (void)drawNumberOfQuads:(NSUInteger)n fromIndex:(NSUInteger)start
Availability
Declared In
CCTextureAtlas.h
fillWithEmptyQuadsFromIndex:amount:
Ensures that after a realloc quads are still empty Used internally by CCParticleBatchNode
- (void)fillWithEmptyQuadsFromIndex:(NSUInteger)index amount:(NSUInteger)amount
Availability
Declared In
CCTextureAtlas.h
increaseTotalQuadsWith:
Used internally by CCParticleBatchNode don’t use this unless you know what you’re doing
- (void)increaseTotalQuadsWith:(NSUInteger)amount
Availability
Declared In
CCTextureAtlas.h
initWithFile:capacity:
initializes a TextureAtlas with a filename and with a certain capacity for Quads. The TextureAtlas capacity can be increased in runtime.
- (id)initWithFile:(NSString *)file capacity:(NSUInteger)capacity
Discussion
WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
Declared In
CCTextureAtlas.h
initWithTexture: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.
- (id)initWithTexture:(CCTexture2D *)tex capacity:(NSUInteger)capacity
Discussion
WARNING: Do not reinitialize the TextureAtlas because it will leak memory (issue #706)
Declared In
CCTextureAtlas.h
insertQuad:atIndex:
Inserts a Quad (texture, vertex and color) at a certain index index must be between 0 and the atlas capacity – 1
- (void)insertQuad:(ccV3F_C4B_T2F_Quad *)quad atIndex:(NSUInteger)index
Availability
Declared In
CCTextureAtlas.h
insertQuadFromIndex:atIndex:
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
- (void)insertQuadFromIndex:(NSUInteger)fromIndex atIndex:(NSUInteger)newIndex
Availability
Declared In
CCTextureAtlas.h
insertQuads:atIndex: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
- (void)insertQuads:(ccV3F_C4B_T2F_Quad *)quads atIndex:(NSUInteger)index amount:(NSUInteger)amount
Availability
Declared In
CCTextureAtlas.h
moveQuadsFromIndex:amount:atIndex:
Moves an amount of quads from oldIndex at newIndex
- (void)moveQuadsFromIndex:(NSUInteger)oldIndex amount:(NSUInteger)amount atIndex:(NSUInteger)newIndex
Availability
Declared In
CCTextureAtlas.h
moveQuadsFromIndex:to:
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
- (void)moveQuadsFromIndex:(NSUInteger)index to:(NSUInteger)newIndex
Availability
Declared In
CCTextureAtlas.h
removeAllQuads
removes all Quads. The TextureAtlas capacity remains untouched. No memory is freed. The total number of quads to be drawn will be 0
- (void)removeAllQuads
Availability
Declared In
CCTextureAtlas.h
removeQuadAtIndex:
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
- (void)removeQuadAtIndex:(NSUInteger)index
Availability
Declared In
CCTextureAtlas.h
removeQuadsAtIndex:amount:
removes a amount of quads starting from index
- (void)removeQuadsAtIndex:(NSUInteger)index amount:(NSUInteger)amount
Availability
Declared In
CCTextureAtlas.h
resizeCapacity:
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.
- (BOOL)resizeCapacity:(NSUInteger)n
Declared In
CCTextureAtlas.h