Batch. A Sprite has a position and a
size given as width and height. The position is relative to the origin of the coordinate system specified via
Batch#begin() and the respective matrices. A Sprite is always rectangular and its position (x, y) are located in the
bottom left corner of that rectangle. A Sprite also has an origin around which rotations and scaling are performed (that is,
the origin is not modified by rotation and scaling). The origin is given relative to the bottom left corner of the Sprite, its
position.
| Modifier and Type | Field and Description |
|---|---|
| private Rectangle | |
| private final Color | |
| private boolean | |
| pack-priv float | |
| private float | |
| private float | |
| private float | |
| private float | |
| private float | |
| private float | |
| pack-priv static final int | |
| pack-priv static final int | |
| pack-priv final float[] | |
| pack-priv float | |
| private float | |
| private float |
| Access | Constructor and Description |
|---|---|
| public | |
| public | |
| public | |
| public | Sprite(Texture texture, int srcX, int srcY, int
The width of the texture region. May be negative to flip the sprite when drawn. srcWidth, int The height of the texture region. May be negative to flip the sprite when drawn. srcHeight)Creates a sprite with width, height, and texture region equal to the specified size. |
| public | Sprite(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 |
| public | Sprite(TextureRegion region, int srcX, int srcY, int
The width of the texture region. May be negative to flip the sprite when drawn. srcWidth, int The height of the texture region. May be negative to flip the sprite when drawn. srcHeight)Creates a sprite with width, height, and texture region equal to the specified size, relative to specified sprite's texture region. |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | |
| public void | flip(boolean
perform horizontal flip x, boolean perform vertical flip y)Overrides com. boolean parameters x,y are not setting a state, but performing a flip |
| public Rectangle | Returns: the bounding RectangleReturns the bounding axis aligned |
| public Color | |
| public float | |
| public float | getOriginX()
The origin influences |
| public float | getOriginY()
The origin influences |
| public float | |
| public float | |
| public float | |
| public float | |
| public float[] | |
| public float | |
| public float | |
| public float | |
| public void | |
| public void | rotate90(boolean clockwise)
Rotates this sprite 90 degrees in-place by rotating the texture coordinates. |
| public void | |
| public void | scroll(float xAmount, float yAmount)
Overrides com. Offsets the region relative to the current region. |
| public void | |
| public void | |
| public 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. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | setFlip(boolean
the desired horizontal flip state x, boolean the desired vertical flip state y)Set the sprite's flip state regardless of current condition |
| public void | setOrigin(float originX, float originY)
Sets the origin in relation to the sprite's position for scaling and rotation. |
| public void | setOriginBasedPosition(float x, float y)
Sets the position where the sprite will be drawn, relative to its current origin. |
| public void | |
| public void | |
| public void | |
| public void | setRegion(float u, float v, float u2, float v2)
Overrides com.
|
| public void | |
| public void | |
| public void | |
| public void | setSize(float width, float height)
Sets the size of the sprite when drawn, before scaling and rotation are applied. |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | |
| public void | translate(float xAmount, float yAmount)
Sets the position relative to the current position where the sprite will be drawn. |
| public void | translateX(float xAmount)
Sets the x position relative to the current position where the sprite will be drawn. |
| public void | translateY(float yAmount)
Sets the y position relative to the current position where the sprite will be drawn. |
| bounds | back to summary |
|---|---|
| private Rectangle bounds | |
| color | back to summary |
|---|---|
| private final Color color | |
| dirty | back to summary |
|---|---|
| private boolean dirty | |
| height | back to summary |
|---|---|
| pack-priv float height | |
| originX | back to summary |
|---|---|
| private float originX | |
| originY | back to summary |
|---|---|
| private float originY | |
| packedColor | back to summary |
|---|---|
| private float packedColor | |
| rotation | back to summary |
|---|---|
| private float rotation | |
| scaleX | back to summary |
|---|---|
| private float scaleX | |
| scaleY | back to summary |
|---|---|
| private float scaleY | |
| SPRITE_SIZE | back to summary |
|---|---|
| pack-priv static final int SPRITE_SIZE | |
| VERTEX_SIZE | back to summary |
|---|---|
| pack-priv static final int VERTEX_SIZE | |
| vertices | back to summary |
|---|---|
| pack-priv final float[] vertices | |
| width | back to summary |
|---|---|
| pack-priv float width | |
| x | back to summary |
|---|---|
| private float x | |
| y | back to summary |
|---|---|
| private float y | |
| Sprite | back to summary |
|---|---|
| public Sprite() Creates an uninitialized sprite. The sprite will need a texture region and bounds set before it can be drawn. | |
| Sprite | back to summary |
|---|---|
| public Sprite(Texture texture) Creates a sprite with width, height, and texture region equal to the size of the texture. | |
| Sprite | back to summary |
|---|---|
| public Sprite(Texture texture, int srcWidth, int srcHeight) Creates a sprite with width, height, and texture region equal to the specified size. The texture region's upper left corner will be 0,0.
| |
| Sprite | back to summary |
|---|---|
| public Sprite(Texture texture, int srcX, int srcY, int srcWidth, int srcHeight) Creates a sprite with width, height, and texture region equal to the specified size.
| |
| Sprite | back to summary |
|---|---|
| public Sprite(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 | |
| Sprite | back to summary |
|---|---|
| public Sprite(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.
| |
| Sprite | back to summary |
|---|---|
| public Sprite(Sprite sprite) Creates a sprite that is a copy in every way of the specified sprite. | |
| draw | back to summary |
|---|---|
| public void draw(Batch batch) | |
| draw | back to summary |
|---|---|
| public void draw(Batch batch, float alphaModulation) | |
| flip | back to summary |
|---|---|
| public void flip(boolean x, boolean y) Overrides com. boolean parameters x,y are not setting a state, but performing a flip
| |
| getBoundingRectangle | back to summary |
|---|---|
| public Rectangle getBoundingRectangle() Returns the bounding axis aligned
| |
| getColor | back to summary |
|---|---|
| public Color getColor() Returns the color of this sprite. If the returned instance is manipulated, | |
| getHeight | back to summary |
|---|---|
public float getHeight()
| |
| getOriginX | back to summary |
|---|---|
| public float getOriginX() The origin influences | |
| getOriginY | back to summary |
|---|---|
| public float getOriginY() The origin influences | |
| getPackedColor | back to summary |
|---|---|
| public float getPackedColor() Returns the packed color of this sprite. | |
| getRotation | back to summary |
|---|---|
public float getRotation()
| |
| getScaleX | back to summary |
|---|---|
| public float getScaleX() X scale of the sprite, independent of size set by | |
| getScaleY | back to summary |
|---|---|
| public float getScaleY() Y scale of the sprite, independent of size set by | |
| getVertices | back to summary |
|---|---|
| public float[] getVertices() Returns the packed vertices, colors, and texture coordinates for this sprite. | |
| getWidth | back to summary |
|---|---|
public float getWidth()
| |
| getX | back to summary |
|---|---|
| public float getX() | |
| getY | back to summary |
|---|---|
| public float getY() | |
| rotate | back to summary |
|---|---|
| public void rotate(float degrees) Sets the sprite's rotation in degrees relative to the current rotation. Rotation is centered on the origin set in
| |
| rotate90 | back to summary |
|---|---|
| public void rotate90(boolean clockwise) Rotates this sprite 90 degrees in-place by rotating the texture coordinates. This rotation is unaffected by
| |
| scale | back to summary |
|---|---|
| public void scale(float amount) Sets the sprite's scale relative to the current scale. for example: original scale 2 -> sprite.scale(4) -> final scale 6.
The sprite scales out from the origin. This will not affect the values returned by | |
| scroll | back to summary |
|---|---|
| public void scroll(float xAmount, float yAmount) Overrides com. Doc from com. Offsets the region relative to the current region. Generally the region's size should be the entire size of the texture in the direction(s) it is scrolled. | |
| set | back to summary |
|---|---|
| public void set(Sprite sprite) Make this sprite a copy in every way of the specified sprite | |
| setAlpha | back to summary |
|---|---|
| public void setAlpha(float a) Sets the alpha portion of the color used to tint this sprite. | |
| setBounds | back to summary |
|---|---|
| public 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. If origin, rotation, or scale are changed, it is slightly more efficient to set the bounds after those operations. | |
| setCenter | back to summary |
|---|---|
| public void setCenter(float x, float y) Sets the position so that the sprite is centered on (x, y) | |
| setCenterX | back to summary |
|---|---|
| public void setCenterX(float x) Sets the x position so that it is centered on the given x parameter | |
| setCenterY | back to summary |
|---|---|
| public void setCenterY(float y) Sets the y position so that it is centered on the given y parameter | |
| setColor | back to summary |
|---|---|
| public void setColor(Color tint) Sets the color used to tint this sprite. Default is | |
| setColor | back to summary |
|---|---|
public void setColor(float r, float g, float b, float a)
| |
| setFlip | back to summary |
|---|---|
| public void setFlip(boolean x, boolean y) Set the sprite's flip state regardless of current condition
| |
| setOrigin | back to summary |
|---|---|
| public void setOrigin(float originX, float originY) Sets the origin in relation to the sprite's position for scaling and rotation. | |
| setOriginBasedPosition | back to summary |
|---|---|
| public void setOriginBasedPosition(float x, float y) Sets the position where the sprite will be drawn, relative to its current origin. | |
| setOriginCenter | back to summary |
|---|---|
| public void setOriginCenter() Place origin in the center of the sprite | |
| setPackedColor | back to summary |
|---|---|
| public void setPackedColor(float packedColor) Sets the packed color used to tint this sprite.
| |
| setPosition | back to summary |
|---|---|
| public void setPosition(float x, float y) Sets the position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more efficient
to set the position after those operations. If both position and size are to be changed, it is better to use
| |
| setRegion | back to summary |
|---|---|
| public void setRegion(float u, float v, float u2, float v2) Overrides com. | |
| setRotation | back to summary |
|---|---|
| public void setRotation(float degrees) Sets the rotation of the sprite in degrees. Rotation is centered on the origin set in | |
| setScale | back to summary |
|---|---|
| public void setScale(float scaleXY) Sets the sprite's scale for both X and Y uniformly. The sprite scales out from the origin. This will not affect the values
returned by | |
| setScale | back to summary |
|---|---|
| public void setScale(float scaleX, float scaleY) Sets the sprite's scale for both X and Y. The sprite scales out from the origin. This will not affect the values returned
by | |
| setSize | back to summary |
|---|---|
| public void setSize(float width, float height) Sets the size of the sprite when drawn, before scaling and rotation are applied. If origin, rotation, or scale are changed,
it is slightly more efficient to set the size after those operations. If both position and size are to be changed, it is
better to use | |
| setU | back to summary |
|---|---|
| public void setU(float u) | |
| setU2 | back to summary |
|---|---|
| public void setU2(float u2) Overrides com. | |
| setV | back to summary |
|---|---|
| public void setV(float v) | |
| setV2 | back to summary |
|---|---|
| public void setV2(float v2) Overrides com. | |
| setX | back to summary |
|---|---|
| public void setX(float x) Sets the x position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more
efficient to set the position after those operations. If both position and size are to be changed, it is better to use
| |
| setY | back to summary |
|---|---|
| public void setY(float y) Sets the y position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more
efficient to set the position after those operations. If both position and size are to be changed, it is better to use
| |
| translate | back to summary |
|---|---|
| public void translate(float xAmount, float yAmount) Sets the position relative to the current position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more efficient to translate after those operations. | |
| translateX | back to summary |
|---|---|
| public void translateX(float xAmount) Sets the x position relative to the current position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more efficient to translate after those operations. | |
| translateY | back to summary |
|---|---|
| public void translateY(float yAmount) Sets the y position relative to the current position where the sprite will be drawn. If origin, rotation, or scale are changed, it is slightly more efficient to translate after those operations. | |