TilemapTmxParser
Internal parser for TMX (Tiled Map Editor) format files.
This class handles the low-level parsing of TMX XML data using the format.tmx library, including support for external TSX tileset files. It implements caching for TSX files to improve performance when multiple maps reference the same tilesets.
Features
- TMX Parsing: Converts TMX XML to structured data
- TSX Support: Resolves and caches external tileset files
- Error Handling: Catches and logs parsing errors
- Caching: Maintains cache of parsed TSX files by path
Internal Usage
This class is used internally by TilemapParser and should not be instantiated directly. Use TilemapParser.parseTmx() instead.
Instance Members
Parses raw TMX XML data into a structured TmxMap object.
Name | Type | Default | Description |
---|---|---|---|
rawTmxData |
String | The TMX file content as an XML string | |
cwd |
String | Current working directory for resolving relative TSX paths | |
resolveTsxRawData |
Function | (optional) | Optional callback to load external TSX files. If not provided, external tilesets will not be resolved |
Returns | Description |
---|---|
format.tmx.TmxMap | Parsed TmxMap object, or null if parsing fails |
Creates a new TMX parser instance.
Private Members
Cache for parsed TSX tileset files, keyed by "cwd:filename". Prevents re-parsing the same tileset multiple times.
TMX reader instance from the format.tmx library.
Current working directory for resolving relative TSX paths.
Callback function to resolve external TSX file data. Provided by the caller to load TSX files from disk or assets.
Name | Type |
---|---|
name |
String |
cwd |
String |
Returns |
---|
String |
Clears the TSX cache, forcing re-parsing of tileset files. Only accessible by TilemapParser.
Resolves and returns a TSX tileset, using cache when available. Called by the TMX reader when it encounters an external tileset reference.
Name | Type | Description |
---|---|---|
name |
String | The TSX filename referenced in the TMX |
Returns | Description |
---|---|
format.tmx.TmxTileset | The parsed TmxTileset object |