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

// Add a tilemap asset
assets.addTilemap('level1');

// Load and use tilemap data
assets.onceComplete(this, function(success) {
    var tilemapData = assets.tilemap('level1');
    var tilemap = new Tilemap();
    tilemap.tilemapData = tilemapData;
});

// Access LDtk data (if available)
var ldtkData = assets.ldtk('myLevel');

Static Members

ldtk
ldtk(assets: Assets, name: Either<String, AssetId<String>>): LdtkData

Gets the LdtkData from a loaded LDtk tilemap asset. Only available when the ldtk plugin is enabled.

Name Type Description
assets Assets The assets manager
name Either<String, AssetId<String>> The LDtk file name or asset ID
Returns Description
LdtkData The LdtkData instance, or null if not found or not an LDtk file

tilemap
addTilemap(assets: Assets, name: String, ?variant: String, ?options: Null<AssetOptions>): Void

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

tilemap
ensureTilemap(assets: Assets, name: Either<String, AssetId<String>>, ?variant: String, ?options: Null<AssetOptions>, done: Function): Void

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)

tilemap
tilemap(assets: Assets, name: Either<String, AssetId<String>>, ?variant: String): TilemapData

Gets the TilemapData from a loaded tilemap asset. Returns null if the asset is not found or not loaded.

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
Returns Description
TilemapData The TilemapData instance, or null if not found

tilemap
tilemapAsset(assets: Assets, name: Either<String, AssetId<String>>, ?variant: String): TilemapAsset

Gets the TilemapAsset instance for the given name. Searches in the current assets manager and its parents.

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
Returns Description
TilemapAsset The TilemapAsset instance, or null if not found

tilemap
getTilemapParser(assets: Assets): TilemapParser

Return the tilemap parser instance associated with this Assets object. The first time, creates an instance, then reuses it.

Name Type Description
assets Assets *
Returns Description
TilemapParser TilemapParser

tilemap
getRawTsxCache(assets: Assets): Map

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.

Metadata

Name Parameters
:access ceramic.App