LdtkLevel

ceramic.LdtkLevel (Class)

Represents a single level in an LDtk world.

Contains all the layer instances, entities, and properties for one game level. Levels can reference external data files in multi-file projects.

Each level has:

  • Position in world coordinates
  • Background settings
  • Layer instances with tiles and entities
  • Custom field values

Instance Members

ldtk
world: LdtkWorld

The LdtkWorld object this level belong to


ldtk
ceramicTilemap: TilemapData

The Ceramic tilemap generated from this level


ldtk
bgColor: Color

Background color of the level


Position informations of the background image, if there is one. (can be null)


ldtk
bgRelPath: String

The optional relative path to the level background image. (can be null)


ldtk
neighbours: Array<LdtkLevelNeighbour>

An array listing all other levels touching this one on the world map. Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, this array is always empty.


ldtk
externalRelPath: String

This value is not null if the project option "Save levels separately" is enabled. In this case, this relative path points to the level Json file.


ldtk
fieldInstances: Array<LdtkFieldInstance>

An array containing this level custom field values.


ldtk
identifier: String

User defined unique identifier


ldtk
iid: String

Unique instance identifier


ldtk
layerInstances: Array<LdtkLayerInstance>

An array containing all Layer instances. IMPORTANT: if the project option "Save levels separately" is enabled, this field will be null. This array is sorted in display order: the 1st layer is the top-most and the last is behind.


ldtk
pxWid: Int

Width of the level in pixels


ldtk
pxHei: Int

Height of the level in pixels


ldtk
uid: Int

Unique Int identifier


ldtk
worldDepth: Int

Index that represents the "depth" of the level in the world. Default is 0, greater means "above", lower means "below". This value is mostly used for display only and is intended to make stacking of levels easier to manage.


ldtk
worldX: Int

World X coordinate in pixels. Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.


ldtk
worldY: Int

World Y coordinate in pixels. Only relevant for world layouts where level spatial positioning is manual (ie. GridVania, Free). For Horizontal and Vertical layouts, the value is always -1 here.


ldtk
ensureLoaded(done: Function): Void
Name Type
done Function

ldtk
unload(): Void

ldtk
layerInstance(identifier: String): LdtkLayerInstance
Name Type
identifier String
Returns
LdtkLayerInstance

ldtk
fieldInstance(identifier: String): LdtkFieldInstance
Name Type
identifier String
Returns
LdtkFieldInstance

ldtk
mapEntities(identifier: String, callback: Function): Void

Walk through every entity instance in the level. Optionally filter by identifier. The callback will be called for each matching entity instance.

Name Type
identifier String
callback Function

ldtk
createVisualsForEntities(tilemap: Tilemap, ?identifier: String, ?createVisual: Function): Void

Create visuals for every entity instance in the level. Optionally filter by identifier. If provided, the createVisual callback will be called for every entity, and this callback can either return a Visual instance or null.

If a visual is created, it will be added at the correct depth in the tilemap object, inside the correct layer.

If createVisual is not provided, this method will create instances of LdtkVisual, which are built-in visuals that will display entities that are renderable.

Name Type Default
tilemap Tilemap
identifier String (optional)
createVisual Function (optional)

ldtk
toString(): String
Returns
String

ldtk
new(?ldtkData: LdtkData, ?world: LdtkWorld, ?json: haxe.DynamicAccess<Dynamic>): Void
Name Type Default
ldtkData LdtkData (optional)
world LdtkWorld (optional)
json haxe.DynamicAccess<Dynamic> (optional)

Private Members