sprites or textures, first call SpriteCache#beginCache(), then call the
appropriate add method to define the images. To complete the cache, call SpriteCache#endCache() and store the returned
cache ID.begin(), then call draw(int) with a cache ID. When SpriteCache drawing
is complete, call end().resized, the SpriteCache's matrices must be updated. For example:cache.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight());draw(int).| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private Array | |
| private final Color | |
| private float | |
| private final Matrix4 | |
| private final IntArray | |
| private SpriteCache. | |
| private ShaderProgram | |
| private boolean | |
| private final Mesh | |
| private final Matrix4 | |
| public int | renderCalls
Number of render calls since the last |
| private final ShaderProgram | |
| private static final float[] | |
| private final Array | |
| public int | totalRenderCalls
Number of rendering calls, ever. |
| private final Matrix4 |
| Access | Constructor and Description |
|---|---|
| public | |
| public | SpriteCache(int
The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
Max of 8191 if indices are used. size, boolean If true, indexed geometry will be used. useIndices)Creates a cache with the specified size, using a default shader if OpenGL ES 2.0 is being used. |
| public | SpriteCache(int
The maximum number of images this cache can hold. The memory required to hold the images is allocated up front.
Max of 8191 if indices are used. size, ShaderProgram shader, boolean If true, indexed geometry will be used. useIndices)Creates a cache with the specified size and OpenGL ES 2.0 shader. |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | add(TextureRegion region, float x, float y, float width, float height)
Adds the specified region to the cache. |
| public void | add(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation)
Adds the specified region to the cache. |
| public void | |
| public void | |
| public void | beginCache()
Starts the definition of a new cache, allowing the add and |
| public void | beginCache(int cacheID)
Starts the redefinition of an existing cache, allowing the add and |
| public void | |
| pack-priv static ShaderProgram | |
| public void | dispose()
Implements com. Releases all resources held by this SpriteCache. |
| public void | |
| public void | draw(int cacheID, int
The first image to render. offset, int The number of images from the first image (inclusive) to render. length)Draws a subset of images defined for the specified cache ID. |
| public void | |
| public int | |
| public Color | |
| public ShaderProgram | |
| public float | |
| public Matrix4 | |
| public Matrix4 | |
| public boolean | |
| public void | |
| public void | |
| public void | setPackedColor(float packedColor)
Sets the color of this sprite cache, expanding the alpha from 0-254 to 0-255. |
| public void | |
| public void | setShader(ShaderProgram
the shader)ShaderProgram or null to use the default shader.Sets the shader to be used in a GLES 2.0 environment. |
| public void |
| caches | back to summary |
|---|---|
| private Array<SpriteCache. | |
| color | back to summary |
|---|---|
| private final Color color | |
| colorPacked | back to summary |
|---|---|
| private float colorPacked | |
| combinedMatrix | back to summary |
|---|---|
| private final Matrix4 combinedMatrix | |
| counts | back to summary |
|---|---|
| private final IntArray counts | |
| currentCache | back to summary |
|---|---|
| private SpriteCache. | |
| customShader | back to summary |
|---|---|
| private ShaderProgram customShader | |
| drawing | back to summary |
|---|---|
| private boolean drawing | |
| mesh | back to summary |
|---|---|
| private final Mesh mesh | |
| projectionMatrix | back to summary |
|---|---|
| private final Matrix4 projectionMatrix | |
| renderCalls | back to summary |
|---|---|
| public int renderCalls Number of render calls since the last | |
| shader | back to summary |
|---|---|
| private final ShaderProgram shader | |
| tempVertices | back to summary |
|---|---|
| private static final float[] tempVertices | |
| textures | back to summary |
|---|---|
| private final Array<Texture> textures | |
| totalRenderCalls | back to summary |
|---|---|
| public int totalRenderCalls Number of rendering calls, ever. Will not be reset unless set manually. | |
| transformMatrix | back to summary |
|---|---|
| private final Matrix4 transformMatrix | |
| SpriteCache | back to summary |
|---|---|
| public SpriteCache() Creates a cache that uses indexed geometry and can contain up to 1000 images. | |
| SpriteCache | back to summary |
|---|---|
| public SpriteCache(int size, boolean useIndices) Creates a cache with the specified size, using a default shader if OpenGL ES 2.0 is being used.
| |
| SpriteCache | back to summary |
|---|---|
| public SpriteCache(int size, ShaderProgram shader, boolean useIndices) Creates a cache with the specified size and OpenGL ES 2.0 shader.
| |
| add | back to summary |
|---|---|
| public void add(Texture texture, float[] vertices, int offset, int length) Adds the specified vertices to the cache. Each vertex should have 5 elements, one for each of the attributes: x, y, color, u, and v. If indexed geometry is used, each image should be specified as 4 vertices, otherwise each image should be specified as 6 vertices. | |
| add | back to summary |
|---|---|
| public void add(Texture texture, float x, float y) Adds the specified texture to the cache. | |
| add | back to summary |
|---|---|
| public void add(Texture texture, float x, float y, int srcWidth, int srcHeight, float u, float v, float u2, float v2, float color) Adds the specified texture to the cache. | |
| add | back to summary |
|---|---|
| public void add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight) Adds the specified texture to the cache. | |
| add | back to summary |
|---|---|
| public void add(Texture texture, float x, float y, float width, float height, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY) Adds the specified texture to the cache. | |
| add | back to summary |
|---|---|
| public void add(Texture texture, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY) Adds the specified texture to the cache. | |
| add | back to summary |
|---|---|
| public void add(TextureRegion region, float x, float y) Adds the specified region to the cache. | |
| add | back to summary |
|---|---|
| public void add(TextureRegion region, float x, float y, float width, float height) Adds the specified region to the cache. | |
| add | back to summary |
|---|---|
| public void add(TextureRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) Adds the specified region to the cache. | |
| add | back to summary |
|---|---|
| public void add(Sprite sprite) Adds the specified sprite to the cache. | |
| begin | back to summary |
|---|---|
| public void begin() Prepares the OpenGL state for SpriteCache rendering. | |
| beginCache | back to summary |
|---|---|
| public void beginCache() Starts the definition of a new cache, allowing the add and | |
| beginCache | back to summary |
|---|---|
| public void beginCache(int cacheID) Starts the redefinition of an existing cache, allowing the add and | |
| clear | back to summary |
|---|---|
| public void clear() Invalidates all cache IDs and resets the SpriteCache so new caches can be added. | |
| createDefaultShader | back to summary |
|---|---|
| pack-priv static ShaderProgram createDefaultShader() | |
| dispose | back to summary |
|---|---|
| public void dispose() Implements com. Releases all resources held by this SpriteCache. | |
| draw | back to summary |
|---|---|
| public void draw(int cacheID) Draws all the images defined for the specified cache ID. | |
| draw | back to summary |
|---|---|
| public void draw(int cacheID, int offset, int length) Draws a subset of images defined for the specified cache ID.
| |
| end | back to summary |
|---|---|
| public void end() Completes rendering for this SpriteCache. | |
| endCache | back to summary |
|---|---|
| public int endCache() Ends the definition of a cache, returning the cache ID to be used with | |
| getColor | back to summary |
|---|---|
| public Color getColor() | |
| getCustomShader | back to summary |
|---|---|
| public ShaderProgram getCustomShader() Returns the custom shader, or null if the default shader is being used. | |
| getPackedColor | back to summary |
|---|---|
| public float getPackedColor() | |
| getProjectionMatrix | back to summary |
|---|---|
| public Matrix4 getProjectionMatrix() | |
| getTransformMatrix | back to summary |
|---|---|
| public Matrix4 getTransformMatrix() | |
| isDrawing | back to summary |
|---|---|
| public boolean isDrawing() | |
| setColor | back to summary |
|---|---|
| public void setColor(Color tint) Sets the color used to tint images when they are added to the SpriteCache. Default is | |
| setColor | back to summary |
|---|---|
public void setColor(float r, float g, float b, float a)
| |
| setPackedColor | back to summary |
|---|---|
| public void setPackedColor(float packedColor) Sets the color of this sprite cache, expanding the alpha from 0-254 to 0-255.
| |
| setProjectionMatrix | back to summary |
|---|---|
| public void setProjectionMatrix(Matrix4 projection) | |
| setShader | back to summary |
|---|---|
| public void setShader(ShaderProgram shader) Sets the shader to be used in a GLES 2.0 environment. Vertex position attribute is called "a_position", the texture coordinates attribute is called called "a_texCoords", the color attribute is called "a_color". The projection matrix is uploaded via a mat4 uniform called "u_proj", the transform matrix is uploaded via a uniform called "u_trans", the combined transform and projection matrx is is uploaded via a mat4 uniform called "u_projTrans". The texture sampler is passed via a uniform called "u_texture". Call this method with a null argument to use the default shader.
| |
| setTransformMatrix | back to summary |
|---|---|
| public void setTransformMatrix(Matrix4 transform) | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int[] | |
| pack-priv final int | |
| pack-priv int | |
| pack-priv final int | |
| pack-priv int | |
| pack-priv Texture[] |
| Access | Constructor and Description |
|---|---|
| public |
| counts | back to summary |
|---|---|
| pack-priv int[] counts | |
| id | back to summary |
|---|---|
| pack-priv final int id | |
| maxCount | back to summary |
|---|---|
| pack-priv int maxCount | |
| offset | back to summary |
|---|---|
| pack-priv final int offset | |
| textureCount | back to summary |
|---|---|
| pack-priv int textureCount | |
| textures | back to summary |
|---|---|
| pack-priv Texture[] textures | |
| Cache | back to summary |
|---|---|
| public Cache(int id, int offset) | |