Class TextureAtlas


public class TextureAtlas
Represents a texture atlas, which is a collection of images packed into a single image. This class provides methods to read the texture atlas from an XML file and access its properties.
  • Method Details

    • read

      public static TextureAtlas read(String textureAtlasFile)
      Reads a TextureAtlas from the specified XML file.
      Parameters:
      textureAtlasFile - The path to the XML file containing the texture atlas data.
      Returns:
      The TextureAtlas object read from the file, or null if the file could not be read.
    • getAbsoluteImagePath

      public String getAbsoluteImagePath()
      Gets the absolute image path of the texture atlas.
      Returns:
      The absolute image path.
    • getWidth

      public int getWidth()
      Gets the width of the texture atlas.
      Returns:
      The width of the texture atlas.
    • getHeight

      public int getHeight()
      Gets the height of the texture atlas.
      Returns:
      The height of the texture atlas.
    • getSprites

      public List<TextureAtlas.Sprite> getSprites()
      Gets the list of sprites in the texture atlas. If the list is null, it initializes a new empty list.
      Returns:
      The list of sprites.
    • getSprite

      public TextureAtlas.Sprite getSprite(String name)
      Retrieves a sprite by its name from the texture atlas.
      Parameters:
      name - The name of the sprite to retrieve.
      Returns:
      The sprite with the specified name, or null if no such sprite exists.
    • setImagePath

      public void setImagePath(String imagePath)
      Sets the image path for the texture atlas.
      Parameters:
      imagePath - The new image path to set.
    • setWidth

      public void setWidth(int width)
      Sets the width of the texture atlas.
      Parameters:
      width - The new width to set.
    • setHeight

      public void setHeight(int height)
      Sets the height of the texture atlas.
      Parameters:
      height - The new height to set.
    • setSprites

      public void setSprites(List<TextureAtlas.Sprite> sprites)
      Sets the list of sprites in the texture atlas.
      Parameters:
      sprites - The new list of sprites to set.