LDtkLevelDefinition

@Serializable
data class LDtkLevelDefinition(val bgColor: String, val bgPos: LDtkLevelBackgroundPositionData? = null, val neighbours: List<LDtkNeighbourLevelData>?, val levelBgColor: String? = null, val bgPivotX: Float, val bgPivotY: Float, val levelBgPos: LDtkBgPos? = null, val bgRelPath: String? = null, val externalRelPath: String? = null, val fieldInstances: List<LDtkFieldInstance>, val identifier: String, val layerInstances: List<LDtkLayerInstance>? = null, val pxHei: Int, val pxWid: Int, val uid: Int, val worldX: Int, val worldY: Int, val iid: String = "", val worldDepth: Int = 0)

This section contains all the level data. It can be found in 2 distinct forms, depending on Project current settings: - If "Separate level files" is disabled (default): full level data is embedded inside the main Project JSON file, - If "Separate level files" is enabled: level data is stored in separate standalone .ldtkl files (one per level). In this case, the main Project JSON file will still contain most level data, except heavy sections, like the layerInstances array (which will be null). The externalRelPath string points to the ldtkl file. A ldtkl file is just a JSON file containing exactly what is described below.

Constructors

Link copied to clipboard
fun LDtkLevelDefinition(bgColor: String, bgPos: LDtkLevelBackgroundPositionData? = null, neighbours: List<LDtkNeighbourLevelData>?, levelBgColor: String? = null, bgPivotX: Float, bgPivotY: Float, levelBgPos: LDtkBgPos? = null, bgRelPath: String? = null, externalRelPath: String? = null, fieldInstances: List<LDtkFieldInstance>, identifier: String, layerInstances: List<LDtkLayerInstance>? = null, pxHei: Int, pxWid: Int, uid: Int, worldX: Int, worldY: Int, iid: String = "", worldDepth: Int = 0)

Properties

Link copied to clipboard

Background color of the level (same as bgColor, except the default value is automatically used here if its value is null)

Link copied to clipboard

Background image X pivot (0-1)

Link copied to clipboard

Background image Y pivot (0-1)

Link copied to clipboard

Position informations of the background image, if there is one.

Link copied to clipboard
val bgRelPath: String? = null

The optional relative path to the level background image.

Link copied to clipboard
val externalRelPath: String? = null

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.

Link copied to clipboard

An array containing this level custom field values.

Link copied to clipboard

Unique String identifier

Link copied to clipboard
val iid: String

Unique instance identifier

Link copied to clipboard

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.

Link copied to clipboard
val levelBgColor: String? = null

Background color of the level. If null, the project defaultLevelBgColor should be used.

Link copied to clipboard
val levelBgPos: LDtkBgPos? = null

An enum defining the way the background image (if any) is positioned on the level. See __bgPos for resulting position info. Possible values: <null>, Unscaled, Contain, Cover, CoverDirty

Link copied to clipboard

An array listing all other levels touching this one on the world map. In "linear" world layouts, this array is populated with previous/next levels in array, and dir depends on the linear horizontal/vertical layout.

Link copied to clipboard
val pxHei: Int

Height of the level in pixels

Link copied to clipboard
val pxWid: Int

Width of the level in pixels

Link copied to clipboard
val uid: Int

Unique Int identifier

Link copied to clipboard
val worldDepth: Int = 0

Index that represents the "depth" of the level in the world. Default is 0, greater means "above", lower means "below".

Link copied to clipboard
val worldX: Int

World X coordinate in pixels.

Link copied to clipboard
val worldY: Int

World Y coordinate in pixels.