TilemapPlugin
ceramic.TilemapPlugin (Class)
Main plugin class that integrates tilemap support into Ceramic.
The TilemapPlugin extends the asset system to support loading and managing tilemap files,
including TMX (Tiled Map Editor) and optionally LDtk formats. It provides convenience
methods for working with tilemap assets and manages parser instances and caching.
Features
- Asset Integration: Adds 'tilemap' asset kind to the asset system
- Format Support: TMX files, with optional LDtk support
- Parser Management: Maintains parser instances per Assets object
- TSX Caching: Caches external tileset data for performance
- Type Conversion: Registers TilemapData converter for serialization
Usage Example
assets.addTilemap('level1');
assets.onceComplete(this, function(success) {
var tilemapData = assets.tilemap('level1');
var tilemap = new Tilemap();
tilemap.tilemapData = tilemapData;
});
var ldtkData = assets.ldtk('myLevel');
Static Members
Gets the LdtkData from a loaded LDtk tilemap asset.
Only available when the ldtk plugin is enabled.
Returns |
Description |
LdtkData |
The LdtkData instance, or null if not found or not an LDtk file |
Adds a tilemap asset to the asset manager.
The tilemap will be loaded from a file with the given name and appropriate extension (.tmx or .ldtk).
Name |
Type |
Default |
Description |
assets |
Assets |
|
The assets manager to add the tilemap to |
name |
String |
|
The name of the tilemap file (without extension) |
variant |
String |
(optional) |
Optional variant suffix for the file |
options |
Null<AssetOptions> |
(optional) |
Optional asset loading options |
Ensures a tilemap asset is loaded, loading it if necessary.
This method is useful when you need to guarantee an asset is available before using it.
Name |
Type |
Default |
Description |
assets |
Assets |
|
The assets manager |
name |
Either<String, AssetId<String>> |
|
The tilemap name or asset ID |
variant |
String |
(optional) |
Optional variant suffix |
options |
Null<AssetOptions> |
(optional) |
Optional loading options |
done |
Function |
|
Callback that receives the loaded TilemapAsset (or null if loading failed) |
Gets the TilemapData from a loaded tilemap asset.
Returns null if the asset is not found or not loaded.
Returns |
Description |
TilemapData |
The TilemapData instance, or null if not found |
Gets the TilemapAsset instance for the given name.
Searches in the current assets manager and its parents.
Returns |
Description |
TilemapAsset |
The TilemapAsset instance, or null if not found |
Return the tilemap parser instance associated with this Assets
object.
The first time, creates an instance, then reuses it.
Name |
Type |
Description |
assets |
Assets |
* |
Return a string map to read and store raw TSX cached data
Name |
Type |
Description |
assets |
Assets |
* |
Returns |
Description |
Map |
Map<String,String> |
Private Members
tilemap
pluginInit(): Void
Initializes the tilemap plugin during application startup.
This method is called automatically by the plugin system.
Registers the 'tilemap' asset kind and sets up converters.
Name |
Parameters |
:access |
ceramic.App |