Class cc.TextureAtlas
Extends
cc.Class.
Defined in: CCTextureAtlas.js.
Constructor Attributes | Constructor Name and Description |
---|---|
A class that implements a Texture Atlas. |
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
|
|
drawNumberOfQuads(n, start)
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
|
|
getQuads()
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 |
|
insertQuad(quad, index)
Inserts a Quad (texture, vertex and color) at a certain index |
|
insertQuadFromIndex(fromIndex, newIndex)
Removes the quad that is located at a certain index and inserts it at a new index |
|
Removes all Quads. |
|
removeQuadAtIndex(index)
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 |
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.
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}
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}
- Returns:
- {String}
Draws n quads from an index (offset).
n + start can't be greater than the capacity of the atlas
- Parameters:
- {Number} n
- {Number} start
- Returns:
- {Number}
- Returns:
- {Array}
- Returns:
- {Image}
- Returns:
- {Number}
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}
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}
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
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
Removes all Quads.
The TextureAtlas capacity remains untouched. No memory is freed.
The total number of quads to be drawn will be 0
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
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}
- Parameters:
- {Array} quads
- Parameters:
- {Image} texture
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