Class TextureAtlas.AtlasRegion

java.lang.Object
gaiasky.render.gdx.g2d.TextureRegion
gaiasky.render.gdx.g2d.TextureAtlas.AtlasRegion
Enclosing class:
TextureAtlas

public static class TextureAtlas.AtlasRegion extends TextureRegion
Describes the region of a packed image and provides information about the original image before it was packed.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    int
    The number at the end of the original image file name, or -1 if none.

    When sprites are packed, if the original file name ends with a number, it is stored as the index and is not considered as part of the sprite's name.
    The name of the original image file, up to the first underscore.
    float
    The offset from the left of the original image to the left of the packed image, after whitespace was removed for packing.
    float
    The offset from the bottom of the original image to the bottom of the packed image, after whitespace was removed for packing.
    int
    The height of the image, before whitespace was removed for packing.
    int
    The width of the image, before whitespace was removed and rotation was applied for packing.
    int
    The height of the image, after whitespace was removed for packing.
    int
    The width of the image, after whitespace was removed for packing.
    int[]
    The nine-patch pads, or null if not a nine-patch or the has no padding.
    boolean
    If true, the region has been rotated 90 degrees counter-clockwise.
    int[]
    The nine-patch splits, or null if not a nine-patch.
  • Constructor Summary

    Constructors
    Constructor
    Description
    AtlasRegion(com.badlogic.gdx.graphics.Texture texture, int x, int y, int width, int height)
     
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    flip(boolean x, boolean y)
    Flips the region, adjusting the offset so the image appears to be flip as if no whitespace has been removed for packing.
    float
    Returns the packed height considering the rotate value, if it is true then it returns the packedWidth, otherwise it returns the packedHeight.
    float
    Returns the packed width considering the rotate value, if it is true then it returns the packedHeight, otherwise it returns the packedWidth.
     

    Methods inherited from class TextureRegion

    getRegionHeight, getRegionWidth, getRegionX, getRegionY, getTexture, getU, getU2, getV, getV2, isFlipX, isFlipY, scroll, setRegion, setRegion, setRegion, setRegion, setRegion, setRegionHeight, setRegionWidth, setRegionX, setRegionY, setTexture, setU, setU2, setV, setV2, split, split
    Modifier and Type
    Method
    Description
    int
    Returns the region's height.
    int
    Returns the region's width.
    int
     
    int
     
    com.badlogic.gdx.graphics.Texture
     
    float
     
    float
     
    float
     
    float
     
    boolean
     
    boolean
     
    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(com.badlogic.gdx.graphics.Texture texture)
    Sets the texture and sets the coordinates to the size of the specified texture.
    void
    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(com.badlogic.gdx.graphics.Texture texture)
     
    void
    setU(float u)
     
    void
    setU2(float u2)
     
    void
    setV(float v)
     
    void
    setV2(float v2)
     
    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(com.badlogic.gdx.graphics.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.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • index

      public int index
      The number at the end of the original image file name, or -1 if none.

      When sprites are packed, if the original file name ends with a number, it is stored as the index and is not considered as part of the sprite's name. This is useful for keeping animation frames in order.
      See Also:
    • name

      public String name
      The name of the original image file, up to the first underscore. Underscores denote special instructions to the texture packer.
    • offsetX

      public float offsetX
      The offset from the left of the original image to the left of the packed image, after whitespace was removed for packing.
    • offsetY

      public float offsetY
      The offset from the bottom of the original image to the bottom of the packed image, after whitespace was removed for packing.
    • packedWidth

      public int packedWidth
      The width of the image, after whitespace was removed for packing.
    • packedHeight

      public int packedHeight
      The height of the image, after whitespace was removed for packing.
    • originalWidth

      public int originalWidth
      The width of the image, before whitespace was removed and rotation was applied for packing.
    • originalHeight

      public int originalHeight
      The height of the image, before whitespace was removed for packing.
    • rotate

      public boolean rotate
      If true, the region has been rotated 90 degrees counter-clockwise.
    • splits

      public int[] splits
      The nine-patch splits, or null if not a nine-patch. Has 4 elements: left, right, top, bottom.
    • pads

      public int[] pads
      The nine-patch pads, or null if not a nine-patch or the has no padding. Has 4 elements: left, right, top, bottom.
  • Constructor Details

    • AtlasRegion

      public AtlasRegion(com.badlogic.gdx.graphics.Texture texture, int x, int y, int width, int height)
    • AtlasRegion

      public AtlasRegion(TextureAtlas.AtlasRegion region)
  • Method Details

    • flip

      public void flip(boolean x, boolean y)
      Flips the region, adjusting the offset so the image appears to be flip as if no whitespace has been removed for packing.
      Overrides:
      flip in class TextureRegion
    • getRotatedPackedWidth

      public float getRotatedPackedWidth()
      Returns the packed width considering the rotate value, if it is true then it returns the packedHeight, otherwise it returns the packedWidth.
    • getRotatedPackedHeight

      public float getRotatedPackedHeight()
      Returns the packed height considering the rotate value, if it is true then it returns the packedWidth, otherwise it returns the packedHeight.
    • toString

      public String toString()
      Overrides:
      toString in class Object