public class LibgdxSpriteCache extends java.lang.Object implements SpriteCache
Constructor and Description |
---|
LibgdxSpriteCache() |
Modifier and Type | Method and Description |
---|---|
int |
add(Sprite sprite)
Adds a
Sprite to the cache. |
int |
add(Texture texture,
float x,
float y)
Adds a
Texture to the cache |
int |
add(Texture texture,
float x,
float y,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Adds a region of a
Texture to the cache |
int |
add(Texture texture,
float x,
float y,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
boolean flipX,
boolean flipY)
Adds a region of a
Texture to the cache |
int |
add(Texture texture,
float x,
float y,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
float scaleX,
float scaleY,
boolean flipX,
boolean flipY)
Adds a transformed region of a
Texture to the cache |
int |
add(Texture texture,
float x,
float y,
int srcX,
int srcY,
int srcWidth,
int srcHeight,
float scaleX,
float scaleY,
float originX,
float originY,
float rotation,
boolean flipX,
boolean flipY)
Adds a transformed region of a
Texture to the cache |
int |
add(TextureRegion region,
float x,
float y)
Adds a
TextureRegion to the cache |
int |
add(TextureRegion region,
float x,
float y,
float scaleX,
float scaleY)
Adds a scaled
TextureRegion to the cache |
int |
add(TextureRegion region,
float x,
float y,
float scaleX,
float scaleY,
float originX,
float originY,
float rotation)
Adds a scaled
TextureRegion to the cache |
int |
add(TextureRegion region,
float x,
float y,
float scaleX,
float scaleY,
float originX,
float originY,
float rotation,
boolean flipX,
boolean flipY)
Adds a scaled
TextureRegion to the cache |
void |
beginCache()
Starts the definition of a new cache
|
void |
beginCache(int cacheID)
Starts the redefinition of an existing cache
|
void |
clear()
Invalidates all the caches and resets the SpriteCache.
|
void |
dispose()
Releases all the resources held by this SpriteCache.
|
void |
draw(Graphics g,
int cacheID)
Draws all the images defined in a SpriteCache to the screen.
|
void |
draw(Graphics g,
int cacheID,
int offset,
int length)
Draws a subset of the images defined in a SpriteCache to the screen.
|
int |
endCache()
Ends the definition of the current cache
|
Color |
getColor()
Indicates the
Color currently used to tint images when they are added to the SpriteCache |
Shader |
getCustomShader()
Indicates the custom
Shader used to draw images to the cache |
boolean |
isDrawing()
Indicates if
SpriteCache.beginCache() has been called |
void |
setColor(Color tint)
Sets the
Color used to tint images when they are added to the SpriteCache |
void |
setColor(float r,
float g,
float b,
float a)
Sets the
Color used to tint images when they are added to the SpriteCache |
void |
setCustomShader(Shader shader)
Sets the custom
Shader used to draw images to the cache |
public int add(Sprite sprite)
SpriteCache
Sprite
to the cache.add
in interface SpriteCache
sprite
- The Sprite
to be added.public int add(Texture texture, float x, float y)
SpriteCache
Texture
to the cacheadd
in interface SpriteCache
texture
- The texture to be addedx
- x position of the texturey
- y position of the texturepublic int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight)
SpriteCache
Texture
to the cacheadd
in interface SpriteCache
texture
- the texture to be addedx
- x position of the texturey
- y position of the texturesrcX
- x point in the texturesrcY
- y point in the texturesrcWidth
- width of the region to be drawnsrcHeight
- height of the region to be drawnpublic int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight, boolean flipX, boolean flipY)
SpriteCache
Texture
to the cacheadd
in interface SpriteCache
texture
- the texture to be addedx
- x position of the texturey
- y position of the texturesrcX
- x point in the texturesrcY
- y point in the texturesrcWidth
- width of the region to be drawnsrcHeight
- height of the region to be drawnflipX
- indication of whether the region should be drawn x-flippedflipY
- indication of whether the region should be drawn y-flippedpublic int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight, float scaleX, float scaleY, boolean flipX, boolean flipY)
SpriteCache
Texture
to the cacheadd
in interface SpriteCache
texture
- the texture to be addedx
- x position of the texturey
- y position of the texturesrcX
- x point in the texturesrcY
- y point in the texturesrcWidth
- width of the region to be drawnsrcHeight
- height of the region to be drawnscaleX
- scale of the texture in the x directionscaleY
- scale of the texture in the y directionflipX
- indication of whether the region should be drawn x-flippedflipY
- indication of whether the region should be drawn y-flippedpublic int add(Texture texture, float x, float y, int srcX, int srcY, int srcWidth, int srcHeight, float scaleX, float scaleY, float originX, float originY, float rotation, boolean flipX, boolean flipY)
SpriteCache
Texture
to the cacheadd
in interface SpriteCache
texture
- the texture to be addedx
- x position of the texturey
- y position of the texturesrcX
- x point in the texturesrcY
- y point in the texturesrcWidth
- width of the region to be drawnsrcHeight
- height of the region to be drawnscaleX
- scale of the texture in the x directionscaleY
- scale of the texture in the y directionoriginX
- x position of the point around which the texture should be rotatedoriginY
- y position of the point around which the texture should be rotatedrotation
- rotation of the texture around the origin point (in degrees)flipX
- indication of whether the region should be drawn x-flippedflipY
- indication of whether the region should be drawn y-flippedpublic int add(TextureRegion region, float x, float y)
SpriteCache
TextureRegion
to the cacheadd
in interface SpriteCache
region
- the texture region to be addedx
- x position of the texture regiony
- y position of the texture regionpublic int add(TextureRegion region, float x, float y, float scaleX, float scaleY)
SpriteCache
TextureRegion
to the cacheadd
in interface SpriteCache
region
- the texture region to be addedx
- x position of the texture regiony
- y position of the texture regionscaleX
- scale of the texture region in the x directionscaleY
- scale of the texture region in the y directionpublic int add(TextureRegion region, float x, float y, float scaleX, float scaleY, float originX, float originY, float rotation)
SpriteCache
TextureRegion
to the cacheadd
in interface SpriteCache
region
- the texture region to be addedx
- x position of the texture regiony
- y position of the texture regionscaleX
- scale of the texture region in the x directionscaleY
- scale of the texture region in the y directionoriginX
- x position of the point around which the region should be rotatedoriginY
- y position of the point around which the region should be rotatedrotation
- rotation of the texture around the origin point (in degrees)public int add(TextureRegion region, float x, float y, float scaleX, float scaleY, float originX, float originY, float rotation, boolean flipX, boolean flipY)
SpriteCache
TextureRegion
to the cacheadd
in interface SpriteCache
region
- the texture region to be addedx
- x position of the texture regiony
- y position of the texture regionscaleX
- scale of the texture region in the x directionscaleY
- scale of the texture region in the y directionoriginX
- x position of the point around which the region should be rotatedoriginY
- y position of the point around which the region should be rotatedrotation
- rotation of the texture around the origin point (in degrees)flipX
- indication of whether the region should be drawn x-flippedflipY
- indication of whether the region should be drawn y-flippedpublic void clear()
SpriteCache
clear
in interface SpriteCache
public void dispose()
SpriteCache
dispose
in interface SpriteCache
public void draw(Graphics g, int cacheID)
SpriteCache
draw
in interface SpriteCache
g
- the current Graphics
contextcacheID
- ID of the SpriteCache containing the images to draw.public void draw(Graphics g, int cacheID, int offset, int length)
SpriteCache
draw
in interface SpriteCache
g
- the current Graphics
contextcacheID
- ID of the SpriteCache containing the images to draw.offset
- The index of the first image to drawlength
- The number of the images to drawpublic void beginCache()
SpriteCache
beginCache
in interface SpriteCache
public void beginCache(int cacheID)
SpriteCache
beginCache
in interface SpriteCache
cacheID
- ID of the cache to be redefinedpublic int endCache()
SpriteCache
endCache
in interface SpriteCache
public Color getColor()
SpriteCache
Color
currently used to tint images when they are added to the SpriteCachegetColor
in interface SpriteCache
public void setColor(Color tint)
SpriteCache
Color
used to tint images when they are added to the SpriteCachesetColor
in interface SpriteCache
tint
- the new color to be used to tint images when they are added to the SpriteCachepublic void setColor(float r, float g, float b, float a)
SpriteCache
Color
used to tint images when they are added to the SpriteCachesetColor
in interface SpriteCache
r
- The red value of the new color (0.0-1.0)g
- The green value of the new color (0.0-1.0)b
- The blue value of the new color (0.0-1.0)a
- The alpha value of the new color (0.0-1.0)public Shader getCustomShader()
SpriteCache
Shader
used to draw images to the cachegetCustomShader
in interface SpriteCache
Shader
used to draw images to the cachepublic void setCustomShader(Shader shader)
SpriteCache
Shader
used to draw images to the cachesetCustomShader
in interface SpriteCache
shader
- the new custom Shader
used to draw images to the cachepublic boolean isDrawing()
SpriteCache
SpriteCache.beginCache()
has been calledisDrawing
in interface SpriteCache