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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCustom adapter to convert between String and Boolean values for XML serialization.static classRepresents a sprite in the texture atlas. -
Method Summary
Modifier and TypeMethodDescriptionGets the absolute image path of the texture atlas.intGets the height of the texture atlas.Retrieves a sprite by its name from the texture atlas.Gets the list of sprites in the texture atlas.intgetWidth()Gets the width of the texture atlas.static TextureAtlasReads a TextureAtlas from the specified XML file.voidsetHeight(int height) Sets the height of the texture atlas.voidsetImagePath(String imagePath) Sets the image path for the texture atlas.voidsetSprites(List<TextureAtlas.Sprite> sprites) Sets the list of sprites in the texture atlas.voidsetWidth(int width) Sets the width of the texture atlas.
-
Method Details
-
read
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
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
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
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
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
Sets the list of sprites in the texture atlas.- Parameters:
sprites- The new list of sprites to set.
-