public class TextureRegion extends Object
Constructor and Description |
---|
TextureRegion()
Constructs a region with no texture and no coordinates defined.
|
TextureRegion(Texture texture)
Constructs a region the size of the specified texture.
|
TextureRegion(Texture texture,
float u,
float v,
float u2,
float v2) |
TextureRegion(Texture texture,
int width,
int height) |
TextureRegion(Texture texture,
int x,
int y,
int width,
int height) |
TextureRegion(TextureRegion region)
Constructs a region with the same texture and coordinates of the specified region.
|
TextureRegion(TextureRegion region,
int x,
int y,
int width,
int height)
Constructs a region with the same texture as the specified region and sets the coordinates relative to the specified region.
|
Modifier and Type | Method and Description |
---|---|
void |
flip(boolean x,
boolean y) |
int |
getRegionHeight()
Returns the region's height.
|
int |
getRegionWidth()
Returns the region's width.
|
int |
getRegionX() |
int |
getRegionY() |
Texture |
getTexture() |
float |
getU() |
float |
getU2() |
float |
getV() |
float |
getV2() |
boolean |
isFlipX() |
boolean |
isFlipY() |
void |
scroll(float xAmount,
float yAmount)
Offsets the region relative to the current region.
|
void |
setRegion(float u,
float v,
float u2,
float v2) |
void |
setRegion(int x,
int y,
int width,
int height) |
void |
setRegion(Texture texture)
Sets the texture and sets the coordinates to the size of the specified 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 |
setTexture(Texture texture) |
void |
setU(float u) |
void |
setU2(float u2) |
void |
setV(float v) |
void |
setV2(float v2) |
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.
|
static TextureRegion[][] |
split(Texture texture,
int tileWidth,
int tileHeight)
Helper function to create tiles out of the given
Texture starting from the top left corner going to the right and
ending at the bottom right corner. |
public TextureRegion()
public TextureRegion(Texture texture)
public TextureRegion(Texture texture, int width, int height)
width
- 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 TextureRegion(Texture texture, int x, int y, int width, int height)
width
- 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 TextureRegion(Texture texture, float u, float v, float u2, float v2)
public TextureRegion(TextureRegion region)
public TextureRegion(TextureRegion region, int x, int y, int width, int height)
width
- 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(Texture texture)
public void setRegion(int x, int y, int width, int height)
width
- 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)
public void setRegion(TextureRegion region)
public void setRegion(TextureRegion region, int x, int y, int width, int height)
public Texture getTexture()
public void setTexture(Texture texture)
public float getU()
public void setU(float u)
public float getV()
public void setV(float v)
public float getU2()
public void setU2(float u2)
public float getV2()
public void setV2(float v2)
public int getRegionX()
public void setRegionX(int x)
public int getRegionY()
public void setRegionY(int y)
public int getRegionWidth()
public void setRegionWidth(int width)
public int getRegionHeight()
public void setRegionHeight(int height)
public void flip(boolean x, boolean y)
public boolean isFlipX()
public boolean isFlipY()
public void scroll(float xAmount, float yAmount)
xAmount
- The percentage to offset horizontally.yAmount
- The percentage to offset vertically. This is done in texture space, so up is negative.public TextureRegion[][] split(int tileWidth, int tileHeight)
tileWidth
- a tile's width in pixelstileHeight
- a tile's height in pixelspublic static TextureRegion[][] split(Texture texture, int tileWidth, int tileHeight)
Texture
starting from the top left corner going to the right and
ending at the bottom right corner. Only complete tiles will be returned so if the texture's width or height are not a
multiple of the tile width and height not all of the texture will be used.texture
- the TexturetileWidth
- a tile's width in pixelstileHeight
- a tile's height in pixelsCopyright © 2015. All rights reserved.