com.badlogic.gdx.graphics.g2d
Class PolygonSprite

java.lang.Object
  extended by com.badlogic.gdx.graphics.g2d.PolygonSprite

public class PolygonSprite
extends Object

Author:
Stefan Bachmann, Nathan Sweet

Constructor Summary
PolygonSprite(PolygonRegion region)
           
PolygonSprite(PolygonSprite sprite)
          Creates a sprite that is a copy in every way of the specified sprite.
 
Method Summary
 void draw(PolygonSpriteBatch spriteBatch)
           
 void draw(PolygonSpriteBatch spriteBatch, float alphaModulation)
           
 Rectangle getBoundingRectangle()
          Returns the bounding axis aligned Rectangle that bounds this sprite.
 Color getColor()
          Returns the color of this sprite.
 float getHeight()
           
 float getOriginX()
           
 float getOriginY()
           
 float getRotation()
           
 float getScaleX()
           
 float getScaleY()
           
 float[] getVertices()
          Returns the packed vertices, colors, and texture coordinates for this sprite.
 float getWidth()
           
 float getX()
           
 float getY()
           
 void rotate(float degrees)
          Sets the sprite's rotation relative to the current rotation.
 void scale(float amount)
          Sets the sprite's scale relative to the current scale.
 void set(PolygonSprite 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 setColor(Color tint)
           
 void setColor(float r, float g, float b, float a)
           
 void setOrigin(float originX, float originY)
          Sets the origin in relation to the sprite's position for scaling and rotation.
 void setPosition(float x, float y)
          Sets the position where the sprite will be drawn.
 void setRegion(PolygonRegion region)
           
 void setRotation(float degrees)
           
 void setScale(float scaleXY)
           
 void setScale(float scaleX, float scaleY)
           
 void setSize(float width, float height)
          Sets the size of the sprite when drawn, before scaling and rotation are applied.
 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.
 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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PolygonSprite

public PolygonSprite(PolygonRegion region)

PolygonSprite

public PolygonSprite(PolygonSprite sprite)
Creates a sprite that is a copy in every way of the specified sprite.

Method Detail

set

public void set(PolygonSprite sprite)

setBounds

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.


setSize

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


setPosition

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


setX

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


setY

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


translateX

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

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.


translate

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.


setColor

public void setColor(Color tint)

setColor

public void setColor(float r,
                     float g,
                     float b,
                     float a)

setOrigin

public void setOrigin(float originX,
                      float originY)
Sets the origin in relation to the sprite's position for scaling and rotation.


setRotation

public void setRotation(float degrees)

rotate

public void rotate(float degrees)
Sets the sprite's rotation relative to the current rotation.


setScale

public void setScale(float scaleXY)

setScale

public void setScale(float scaleX,
                     float scaleY)

scale

public void scale(float amount)
Sets the sprite's scale relative to the current scale.


getVertices

public float[] getVertices()
Returns the packed vertices, colors, and texture coordinates for this sprite.


getBoundingRectangle

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:
the bounding Rectangle

draw

public void draw(PolygonSpriteBatch spriteBatch)

draw

public void draw(PolygonSpriteBatch spriteBatch,
                 float alphaModulation)

getX

public float getX()

getY

public float getY()

getWidth

public float getWidth()

getHeight

public float getHeight()

getOriginX

public float getOriginX()

getOriginY

public float getOriginY()

getRotation

public float getRotation()

getScaleX

public float getScaleX()

getScaleY

public float getScaleY()

getColor

public Color getColor()
Returns the color of this sprite. Changing the returned color will have no affect, setColor(Color) or setColor(float, float, float, float) must be used.


setRegion

public void setRegion(PolygonRegion region)


Copyright © 2014. All Rights Reserved.