Class Index | File Index

Classes


Class cc.TextureAtlas


Extends cc.Class.

Defined in: CCTextureAtlas.js.

Class Summary
Constructor Attributes Constructor Name and Description
 

A class that implements a Texture Atlas.

Method Summary
Method Attributes Method Name and Description
<static>  
cc.TextureAtlas.create(file, capacity)

Creates a TextureAtlas with an filename and with an initial capacity for Quads.

<static>  
cc.TextureAtlas.createWithTexture(texture, capacity)

Creates a TextureAtlas with a previously initialized Texture2D object, and with an initial capacity for n Quads.

 
Description
 

Draws n quads from an index (offset).

 
Draws all the Atlas's Quads
 
Quantity of quads that can be stored with the current texture atlas size
 
Quads that are going to be rendered
 
Texture of the texture atlas
 
Quantity of quads that are going to be drawn.
 
initWithFile(file, capacity)

Initializes a TextureAtlas with a filename and with a certain capacity for Quads.

 
initWithTexture(texture, capacity)

Initializes a TextureAtlas with a previously initialized Texture2D object, and
with an initial capacity for Quads.

 
insertQuad(quad, index)

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

 
insertQuadFromIndex(fromIndex, 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

 

Removes all Quads.

 

Removes a quad at a given index number.

 
resizeCapacity(newCapacity)

Resize the capacity of the CCTextureAtlas.

 
setQuads(quads)
 
setTexture(texture)
 
updateQuad(quad, index)

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

Class Detail
cc.TextureAtlas()

A class that implements a Texture Atlas.
Supported features:
The atlas file can be a PNG, JPG.
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.

Method Detail
<static> {cc.TextureAtlas|Null} cc.TextureAtlas.create(file, capacity)

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

//example
var textureAtlas = cc.TextureAtlas.create("hello.png", 3);
Parameters:
{String} file
{Number} capacity
Returns:
{cc.TextureAtlas|Null}

<static> {cc.TextureAtlas} cc.TextureAtlas.createWithTexture(texture, 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.

//example
var texture = cc.TextureCache.getInstance().addImage("hello.png");
var textureAtlas = cc.TextureAtlas.createWithTexture(texture, 3);
Parameters:
{Image} texture
{Number} capacity
Returns:
{cc.TextureAtlas}

{String} description()
Description
Returns:
{String}

drawNumberOfQuads(n, start)

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

Parameters:
{Number} n
{Number} start

drawQuads()
Draws all the Atlas's Quads

{Number} getCapacity()
Quantity of quads that can be stored with the current texture atlas size
Returns:
{Number}

{Array} getQuads()
Quads that are going to be rendered
Returns:
{Array}

{Image} getTexture()
Texture of the texture atlas
Returns:
{Image}

{Number} getTotalQuads()
Quantity of quads that are going to be drawn.
Returns:
{Number}

{Boolean|Null} initWithFile(file, 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.

//example
var textureAtlas = new cc.TextureAtlas();
textureAtlas.initWithTexture("hello.png", 3);
Parameters:
{String} file
{Number} capacity
Returns:
{Boolean|Null}

{Boolean} initWithTexture(texture, 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

//example
var texture = cc.TextureCache.getInstance().addImage("hello.png");
var textureAtlas = new cc.TextureAtlas();
textureAtlas.initWithTexture(texture, 3);
Parameters:
{Image} texture
{Number} capacity
Returns:
{Boolean}

insertQuad(quad, index)

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

Parameters:
{cc.V2F_C4B_T2F_Quad} quad
{Number} index

insertQuadFromIndex(fromIndex, 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

Parameters:
{Number} fromIndex
{Number} newIndex

removeAllQuads()

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


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

Parameters:
{Number} index

{Boolean} resizeCapacity(newCapacity)

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.
no used for js

Parameters:
{Number} newCapacity
Returns:
{Boolean}

setQuads(quads)
Parameters:
{Array} quads

setTexture(texture)
Parameters:
{Image} texture

updateQuad(quad, index)

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

Parameters:
{cc.V2F_C4B_T2F_Quad} quad
{Number} index

Documentation generated by JsDoc Toolkit 2.4.0 on Wed Jan 09 2013 07:51:54 GMT-0800 (PST)