APIdia Launch Partner
Top Fields Constructors Methods
com.badlogic.gdx.graphics.g2d

public Class PolygonSprite

extends Object
Class Inheritance
Imports
com.badlogic.gdx.graphics.Color, com.badlogic.gdx.math.MathUtils, .Rectangle

Authors
Stefan Bachmann, Nathan Sweet

Field Summary

Modifier and TypeField and Description
private Rectangle
private final Color
private boolean
private float
private float
private float
pack-priv PolygonRegion
private float
private float
private float
private float[]
private float
private float
x

private float
y

Constructor Summary

AccessConstructor and Description
public
public
PolygonSprite(PolygonSprite sprite)

Creates a sprite that is a copy in every way of the specified sprite.

Method Summary

Modifier and TypeMethod and Description
public void
draw(PolygonSpriteBatch spriteBatch)

public void
draw(PolygonSpriteBatch spriteBatch, float alphaModulation)

public Rectangle

Returns:

the bounding Rectangle
getBoundingRectangle
()

Returns the bounding axis aligned Rectangle that bounds this sprite.

public Color
getColor()

Returns the color of this sprite.

public float
public float
public float
public Color
getPackedColor()

Returns the actual color used in the vertices of this sprite.

public PolygonRegion
public float
public float
public float
public float[]
getVertices()

Returns the packed vertices, colors, and texture coordinates for this sprite.

public float
public float
getX()

public float
getY()

public void
rotate(float degrees)

Sets the sprite's rotation relative to the current rotation.

public void
scale(float amount)

Sets the sprite's scale relative to the current scale.

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
setColor(float r, float g, float b, float a)

public void
setOrigin(float originX, float originY)

Sets the origin in relation to the sprite's position for scaling and rotation.

public void
setPosition(float x, float y)

Sets the position where the sprite will be drawn.

public void
public void
setRotation(float degrees)

public void
setScale(float scaleXY)

public void
setScale(float scaleX, float scaleY)

public void
setSize(float width, float height)

Sets the size of the sprite when drawn, before scaling and rotation are applied.

public void
setX(float x)

Sets the x position where the sprite will be drawn.

public void
setY(float y)

Sets the y position where the sprite will be drawn.

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.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

boundsback to summary
private Rectangle bounds
colorback to summary
private final Color color
dirtyback to summary
private boolean dirty
heightback to summary
private float height
originXback to summary
private float originX
originYback to summary
private float originY
regionback to summary
pack-priv PolygonRegion region
rotationback to summary
private float rotation
scaleXback to summary
private float scaleX
scaleYback to summary
private float scaleY
verticesback to summary
private float[] vertices
widthback to summary
private float width
xback to summary
private float x
yback to summary
private float y

Constructor Detail

PolygonSpriteback to summary
public PolygonSprite(PolygonRegion region)
PolygonSpriteback to summary
public PolygonSprite(PolygonSprite sprite)

Creates a sprite that is a copy in every way of the specified sprite.

Method Detail

drawback to summary
public void draw(PolygonSpriteBatch spriteBatch)
drawback to summary
public void draw(PolygonSpriteBatch spriteBatch, float alphaModulation)
getBoundingRectangleback to summary
public Rectangle getBoundingRectangle()

Returns the bounding axis aligned Rectangle 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.

Returns:Rectangle

the bounding Rectangle

getColorback to summary
public Color getColor()

Returns the color of this sprite. Modifying the returned color will have unexpected effects unless setColor(Color) or setColor(float, float, float, float) is subsequently called before drawing this sprite.

getHeightback to summary
public float getHeight()
getOriginXback to summary
public float getOriginX()
getOriginYback to summary
public float getOriginY()
getPackedColorback to summary
public Color getPackedColor()

Returns the actual color used in the vertices of this sprite. Modifying the returned color will have unexpected effects unless setColor(Color) or setColor(float, float, float, float) is subsequently called before drawing this sprite.

getRegionback to summary
public PolygonRegion getRegion()
getRotationback to summary
public float getRotation()
getScaleXback to summary
public float getScaleX()
getScaleYback to summary
public float getScaleY()
getVerticesback to summary
public float[] getVertices()

Returns the packed vertices, colors, and texture coordinates for this sprite.

getWidthback to summary
public float getWidth()
getXback to summary
public float getX()
getYback to summary
public float getY()
rotateback to summary
public void rotate(float degrees)

Sets the sprite's rotation relative to the current rotation.

scaleback to summary
public void scale(float amount)

Sets the sprite's scale relative to the current scale.

setback to summary
public void set(PolygonSprite sprite)
setBoundsback 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.

setColorback to summary
public void setColor(Color tint)
setColorback to summary
public void setColor(float r, float g, float b, float a)
setOriginback to summary
public void setOrigin(float originX, float originY)

Sets the origin in relation to the sprite's position for scaling and rotation.

setPositionback 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 setBounds(float, float, float, float).

setRegionback to summary
public void setRegion(PolygonRegion region)
setRotationback to summary
public void setRotation(float degrees)
setScaleback to summary
public void setScale(float scaleXY)
setScaleback to summary
public void setScale(float scaleX, float scaleY)
setSizeback 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 setBounds(float, float, float, float).

setXback 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 setBounds(float, float, float, float).

setYback 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 setBounds(float, float, float, float).

translateback 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.

translateXback 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.

translateYback 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.