ConvertTilemapData
ceramic.ConvertTilemapData (Class)
Implements: ConvertField
Field converter that handles conversion between tilemap asset names (strings) and TilemapData instances. This converter enables automatic loading of tilemap data when deserializing entities from fragments or other data sources.
When a string tilemap name is provided, the converter:
- Uses the Assets system to load the tilemap asset
- Extracts the TilemapData from the loaded asset
- Provides the data to the entity field
This converter is automatically registered by the TilemapPlugin and used whenever a TilemapData field needs to be populated from serialized data.
Usage Example:
// In a fragment or serialized data:
{
"tilemap": "levels/level1" // String asset name
}
// Gets converted to:
entity.tilemap = <TilemapData instance>
See: ConvertField The base interface for field converters, TilemapData The tilemap data structure, TilemapAsset The asset type that contains tilemap data
Instance Members
tilemap
basicToField(instance: Entity, field: String, assets: Assets, basic: String, done: Function): Void
Converts a tilemap asset name (string) to a TilemapData instance. Loads the tilemap asset asynchronously and extracts its data.
Name | Type | Description |
---|---|---|
instance |
Entity | The entity that owns the field being converted |
field |
String | The name of the field being converted |
assets |
Assets | The Assets instance to use for loading |
basic |
String | The tilemap asset name to load |
done |
Function | Callback that receives the loaded TilemapData (or null if loading fails) |
Converts a TilemapData instance back to its asset name string. Used when serializing entities that contain tilemap data.
Name | Type | Description |
---|---|---|
instance |
Entity | The entity that owns the field being converted |
field |
String | The name of the field being converted |
value |
TilemapData | The TilemapData instance to convert |
Returns | Description |
---|---|
String | The asset name string, or null if the data has no associated asset |
Creates a new tilemap data converter instance.