TextureAtlasParser
ceramic.TextureAtlasParser (Class)
Parser for texture atlas definition files in multiple formats.
TextureAtlasParser reads and parses atlas definition files that describe how images are packed into texture pages. It supports:
- LibGDX/Spine text format (.atlas)
- Starling/Sparrow XML format (.xml)
- Automatic format detection based on content
The parser extracts:
- Page definitions with texture file references
- Region coordinates and dimensions
- Trimming information (offsets and original sizes)
- Rotation data for optimally packed regions
- Filtering modes per page
// Parse LibGDX format atlas
var atlasData = Assets.text('sprites.atlas');
var atlas = TextureAtlasParser.parse(atlasData);
// Load textures for each page
for (page in atlas.pages) {
page.texture = Assets.texture(page.name);
}
// Compute UV coordinates
atlas.computeFrames();
See: TextureAtlas The resulting atlas structure, TextureAtlasRegion Individual regions parsed from the file, AtlasAsset For automatic loading and parsing
Static Members
parse(rawTextureAtlas: String): TextureAtlas
Parses a texture atlas definition file into a TextureAtlas instance.
Automatically detects the format based on content:
- XML format: Starts with '<' (Starling/Sparrow)
- Text format: LibGDX/Spine format
The parser handles:
- Multiple pages with different textures
- Regions with trimming and rotation
- Filter settings per page
- Automatic file extension stripping from region names
Name | Type | Description |
---|---|---|
rawTextureAtlas |
String | The raw text content of the atlas file |
Returns | Description |
---|---|
TextureAtlas | Parsed TextureAtlas ready for texture assignment |
Private Members
Converts Starling/Sparrow XML format to LibGDX text format.
This internal method transforms XML atlas definitions into the text-based format that the main parser understands. It extracts:
- Image path from root element
- SubTexture elements with coordinates
- Frame offsets for trimmed sprites
- Rotation flags
Name | Type | Description |
---|---|---|
rawTextureAtlas |
String | XML content to convert |
Returns | Description |
---|---|
String | Equivalent atlas data in text format |