public class LibgdxSprite extends java.lang.Object implements Sprite
| Modifier and Type | Field and Description |
|---|---|
com.badlogic.gdx.graphics.g2d.Sprite |
sprite |
| Constructor and Description |
|---|
LibgdxSprite()
Creates an uninitialized sprite.
|
LibgdxSprite(Sprite sprite)
Creates a sprite that is a copy in every way of the specified sprite.
|
LibgdxSprite(Texture texture)
Creates a sprite with width, height, and texture region equal to the size
of the texture.
|
LibgdxSprite(Texture texture,
int srcWidth,
int srcHeight)
Creates a sprite with width, height, and texture region equal to the
specified size.
|
LibgdxSprite(Texture texture,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Creates a sprite with width, height, and texture region equal to the
specified size.
|
LibgdxSprite(TextureRegion region)
Creates a sprite based on a specific TextureRegion, the new sprite's
region is a copy of the parameter region - altering one does not affect
the other
|
LibgdxSprite(TextureRegion region,
int srcX,
int srcY,
int srcWidth,
int srcHeight)
Creates a sprite with width, height, and texture region equal to the
specified size, relative to specified sprite's texture region.
|
| Modifier and Type | Method and Description |
|---|---|
void |
flip(boolean x,
boolean y) |
float |
getAlpha() |
Rectangle |
getBoundingRectangle()
Returns the bounding axis aligned
Rectangle that bounds this sprite. |
float |
getHeight() |
float |
getOriginX()
The origin influences
Sprite.setPosition(float, float), Sprite.setRotation(float) and the expansion direction of scaling
Sprite.setScale(float, float) |
float |
getOriginY()
The origin influences
Sprite.setPosition(float, float), Sprite.setRotation(float) and the expansion direction of scaling
Sprite.setScale(float, float) |
int |
getRegionHeight()
Returns the region's height.
|
int |
getRegionWidth()
Returns the region's width.
|
int |
getRegionX() |
int |
getRegionY() |
float |
getRotation() |
float |
getScaleX()
X scale of the sprite, independent of size set by
Sprite.setSize(float, float) |
float |
getScaleY()
Y scale of the sprite, independent of size set by
Sprite.setSize(float, float) |
Texture |
getTexture() |
Color |
getTint()
Returns the color of this sprite.
|
float |
getU() |
float |
getU2() |
float |
getV() |
float |
getV2() |
float[] |
getVertices()
Returns the packed vertices, colors, and texture coordinates for this sprite.
|
float |
getWidth() |
float |
getX() |
float |
getY() |
boolean |
isFlipX() |
boolean |
isFlipY() |
void |
rotate(float degrees)
Sets the sprite's rotation in degrees relative to the current rotation.
|
void |
rotate90(boolean clockwise)
Rotates this sprite 90 degrees in-place by rotating the texture coordinates.
|
void |
scale(float amount)
Sets the sprite's scale relative to the current scale.
|
void |
scroll(float xAmount,
float yAmount)
Offsets the region relative to the current region.
|
void |
set(Sprite sprite) |
void |
setAlpha(float a)
Sets the alpha portion of the color used to tint this sprite.
|
void |
setBounds(float x,
float y,
float width,
float height)
Sets the position and size of the sprite when drawn, before scaling and rotation are applied.
|
void |
setCenter(float x,
float y)
Sets the position so that the sprite is centered on (x, y)
|
void |
setCenterX(float x)
Sets the x position so that it is centered on the given x parameter
|
void |
setCenterY(float y)
Sets the y position so that it is centered on the given y parameter
|
void |
setFlip(boolean x,
boolean y)
Set the sprite's flip state regardless of current condition
|
void |
setFlipX(boolean flipX) |
void |
setFlipY(boolean flipY) |
void |
setOrigin(float originX,
float originY)
Sets the origin in relation to the sprite's position for scaling and rotation.
|
void |
setOriginBasedPosition(float x,
float y)
Sets the position where the sprite will be drawn, relative to its current origin.
|
void |
setOriginCenter()
Place origin in the center of the sprite
|
void |
setPosition(float x,
float y)
Sets the position where the sprite will be drawn.
|
void |
setRegion(float u,
float v,
float u2,
float v2) |
void |
setRegion(int x,
int y,
int width,
int height) |
void |
setRegion(Texture texture) |
void |
setRegion(TextureRegion region)
Sets the texture and coordinates to the specified region.
|
void |
setRegion(TextureRegion region,
int x,
int y,
int width,
int height)
Sets the texture to that of the specified region and sets the coordinates relative to the specified region.
|
void |
setRegionHeight(int height) |
void |
setRegionWidth(int width) |
void |
setRegionX(int x) |
void |
setRegionY(int y) |
void |
setRotation(float degrees)
Sets the rotation of the sprite in degrees.
|
void |
setScale(float scaleXY)
Sets the sprite's scale for both X and Y uniformly.
|
void |
setScale(float scaleX,
float scaleY)
Sets the sprite's scale for both X and Y.
|
void |
setSize(float width,
float height)
Sets the size of the sprite when drawn, before scaling and rotation are applied.
|
void |
setTexture(Texture texture) |
void |
setTint(Color tint)
Sets the color used to tint this sprite.
|
void |
setU(float u) |
void |
setU2(float u2) |
void |
setV(float v) |
void |
setV2(float v2) |
void |
setX(float x)
Sets the x position where the sprite will be drawn.
|
void |
setY(float y)
Sets the y position where the sprite will be drawn.
|
TextureRegion[][] |
split(int tileWidth,
int tileHeight)
Helper function to create tiles out of this TextureRegion starting from the top left corner going to the right and ending at
the bottom right corner.
|
Pixmap |
toPixmap()
Converts this
TextureRegion to a Pixmap |
void |
translate(float xAmount,
float yAmount)
Sets the position relative to the current position where the sprite will be drawn.
|
void |
translateX(float xAmount)
Sets the x position relative to the current position where the sprite will be drawn.
|
void |
translateY(float yAmount)
Sets the y position relative to the current position where the sprite will be drawn.
|
public LibgdxSprite()
public LibgdxSprite(Texture texture)
public LibgdxSprite(Texture texture, int srcWidth, int srcHeight)
srcWidth - The width of the texture region. May be negative to flip the
sprite when drawn.srcHeight - The height of the texture region. May be negative to flip the
sprite when drawn.public LibgdxSprite(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight)
srcX - The x coordinate of the region to drawsrcY - The y coordinate of the region to drawsrcWidth - The width of the texture region. May be negative to flip the
sprite when drawn.srcHeight - The height of the texture region. May be negative to flip the
sprite when drawn.public LibgdxSprite(TextureRegion region)
public LibgdxSprite(TextureRegion region, int srcX, int srcY, int srcWidth, int srcHeight)
srcX - The x coordinate of the region to drawsrcY - The y coordinate of the region to drawsrcWidth - The width of the texture region. May be negative to flip the
sprite when drawn.srcHeight - The height of the texture region. May be negative to flip the
sprite when drawn.public LibgdxSprite(Sprite sprite)
public void setBounds(float x,
float y,
float width,
float height)
Spritepublic void setSize(float width,
float height)
SpriteSprite.setBounds(float, float, float, float).public void setPosition(float x,
float y)
SpriteSprite.setBounds(float, float, float, float).setPosition in interface Spritepublic void setOriginBasedPosition(float x,
float y)
SpritesetOriginBasedPosition in interface Spritepublic void setCenterX(float x)
SpritesetCenterX in interface Spritepublic void setCenterY(float y)
SpritesetCenterY in interface Spritepublic void setCenter(float x,
float y)
Spritepublic void translateX(float xAmount)
SpritetranslateX in interface Spritepublic void translateY(float yAmount)
SpritetranslateY in interface Spritepublic void translate(float xAmount,
float yAmount)
Spritepublic void setOrigin(float originX,
float originY)
Spritepublic void setOriginCenter()
SpritesetOriginCenter in interface Spritepublic float getRotation()
getRotation in interface Spritepublic void setRotation(float degrees)
SpriteSprite.setOrigin(float, float)setRotation in interface Spritepublic void rotate(float degrees)
SpriteSprite.setOrigin(float, float)public void rotate90(boolean clockwise)
SpriteSprite.setRotation(float) and Sprite.rotate(float).public void setScale(float scaleXY)
SpriteSprite.getWidth() and Sprite.getHeight()public void setScale(float scaleX,
float scaleY)
SpriteSprite.getWidth() and Sprite.getHeight()public void scale(float amount)
SpriteSprite.getWidth() and
Sprite.getHeight()public float[] getVertices()
SpritegetVertices in interface Spritepublic Rectangle getBoundingRectangle()
SpriteRectangle that bounds this sprite. The rectangles x and y coordinates describe its
bottom left corner. If you change the position or size of the sprite, you have to fetch the triangle again for it to be
recomputed.getBoundingRectangle in interface Spritepublic void setX(float x)
SpriteSprite.setBounds(float, float, float, float).public void setY(float y)
SpriteSprite.setBounds(float, float, float, float).public float getWidth()
public float getHeight()
public float getOriginX()
SpriteSprite.setPosition(float, float), Sprite.setRotation(float) and the expansion direction of scaling
Sprite.setScale(float, float)getOriginX in interface Spritepublic float getOriginY()
SpriteSprite.setPosition(float, float), Sprite.setRotation(float) and the expansion direction of scaling
Sprite.setScale(float, float)getOriginY in interface Spritepublic float getScaleX()
SpriteSprite.setSize(float, float)public float getScaleY()
SpriteSprite.setSize(float, float)public Color getTint()
Spritepublic void setTint(Color tint)
Spritepublic void setRegion(Texture texture)
setRegion in interface TextureRegionpublic void setRegion(int x,
int y,
int width,
int height)
setRegion in interface TextureRegionwidth - The width of the texture region. May be negative to flip the sprite when drawn.height - The height of the texture region. May be negative to flip the sprite when drawn.public void setRegion(float u,
float v,
float u2,
float v2)
setRegion in interface TextureRegionpublic void setRegion(TextureRegion region)
TextureRegionsetRegion in interface TextureRegionpublic void setRegion(TextureRegion region, int x, int y, int width, int height)
TextureRegionsetRegion in interface TextureRegionpublic Texture getTexture()
getTexture in interface TextureRegionpublic void setTexture(Texture texture)
setTexture in interface TextureRegionpublic float getU()
getU in interface TextureRegionpublic void setU(float u)
setU in interface TextureRegionpublic float getV()
getV in interface TextureRegionpublic void setV(float v)
setV in interface TextureRegionpublic float getU2()
getU2 in interface TextureRegionpublic void setU2(float u2)
setU2 in interface TextureRegionpublic float getV2()
getV2 in interface TextureRegionpublic void setV2(float v2)
setV2 in interface TextureRegionpublic int getRegionX()
getRegionX in interface TextureRegionpublic void setRegionX(int x)
setRegionX in interface TextureRegionpublic int getRegionY()
getRegionY in interface TextureRegionpublic void setRegionY(int y)
setRegionY in interface TextureRegionpublic int getRegionWidth()
TextureRegiongetRegionWidth in interface TextureRegionpublic void setRegionWidth(int width)
setRegionWidth in interface TextureRegionpublic int getRegionHeight()
TextureRegiongetRegionHeight in interface TextureRegionpublic void setRegionHeight(int height)
setRegionHeight in interface TextureRegionpublic void flip(boolean x,
boolean y)
flip in interface TextureRegionpublic void setFlip(boolean x,
boolean y)
SpritesetFlip in interface SpritesetFlip in interface TextureRegionx - the desired horizontal flip statey - the desired vertical flip statepublic boolean isFlipX()
isFlipX in interface TextureRegionpublic void setAlpha(float a)
Spritepublic void setFlipX(boolean flipX)
setFlipX in interface SpritesetFlipX in interface TextureRegionpublic boolean isFlipY()
isFlipY in interface TextureRegionpublic void setFlipY(boolean flipY)
setFlipY in interface SpritesetFlipY in interface TextureRegionpublic void scroll(float xAmount,
float yAmount)
TextureRegionscroll in interface TextureRegionxAmount - The percentage to offset horizontally.yAmount - The percentage to offset vertically. This is done in texture space, so up is negative.public Pixmap toPixmap()
TextureRegionTextureRegion to a PixmaptoPixmap in interface TextureRegionPixmap instance containing the pixel datapublic TextureRegion[][] split(int tileWidth, int tileHeight)
TextureRegionsplit in interface TextureRegiontileWidth - a tile's width in pixelstileHeight - a tile's height in pixels