LdtkLayerInstance

ceramic.LdtkLayerInstance (Class)

An instance of a layer in a level.

Contains the actual tile data, entity instances, and int grid values for this specific layer in this specific level.

Instance Members

ldtk
ceramicLayer: TilemapLayerData

The Ceramic layer generated from this level


ldtk
level: LdtkLevel

The LDtk level this layer instance belongs to


The related layer definition


ldtk
opacity: Float

Layer opacity as Float [0-1]


ldtk
cWid: Int

Grid-based width


ldtk
cHei: Int

Grid-based height


ldtk
pxTotalOffsetX: Int

Total layer X pixel offset, including both instance and definition offsets.


ldtk
pxTotalOffsetY: Int

Total layer Y pixel offset, including both instance and definition offsets.


The corresponding Tileset definition, if any.


ldtk
autoLayerTiles: Array<Int>

An array containing all tile info generated by Auto-layer rules. The array is already sorted in display order (ie. 1st tile is beneath 2nd, which is beneath 3rd etc.). Note: if multiple tiles are stacked in the same cell as the result of different rules, all tiles behind opaque ones will be discarded. One tile is stored into 7 int values:

[0] The Tile ID in the corresponding tileset.

[1] "Flip bits", a 2-bits integer to represent the mirror transformations of the tile.

  • Bit 0 = X flip
  • Bit 1 = Y flip

Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips)

[2] Pixel X coordinate of the tile in the layer. Don't forget optional layer offsets, if they exist!

[3] Pixel Y coordinate of the tile in the layer. Don't forget optional layer offsets, if they exist!

[4] Pixel X coordinate of the tile in the tileset.

[5] Pixel Y coordinate of the tile in the tileset.

[6] Pixel alpha [0-4096].


ldtk
entityInstances: Array<LdtkEntityInstance>

Entity instances (only on Entity layers)


ldtk
gridTiles: Array<Int>

Tile instances (only on Tile layers)

One tile is stored into 7 int values:

[0] The Tile ID in the corresponding tileset.

[1] "Flip bits", a 2-bits integer to represent the mirror transformations of the tile.

  • Bit 0 = X flip
  • Bit 1 = Y flip

Examples: f=0 (no flip), f=1 (X flip only), f=2 (Y flip only), f=3 (both flips)

[2] Pixel X coordinate of the tile in the layer. Don't forget optional layer offsets, if they exist!

[3] Pixel Y coordinate of the tile in the layer. Don't forget optional layer offsets, if they exist!

[4] Pixel X coordinate of the tile in the tileset.

[5] Pixel Y coordinate of the tile in the tileset.

[6] Pixel alpha [0-4096].


ldtk
iid: String

Unique layer instance identifier


ldtk
intGrid: Array<Int>

A list of all values in the IntGrid layer Order is from left to right, and top to bottom (ie. first row from left to right, followed by second row, etc). 0 means "empty cell" and IntGrid values start at 1. The array size is cWid x cHei cells. (only IntGrid layers)


ldtk
levelId: Int

Reference to the UID of the level containing this layer instance


ldtk
pxOffsetX: Int

X offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the LayerDef optional offset, so you should probably prefer using pxTotalOffsetX which contains the total offset value)


ldtk
pxOffsetY: Int

Y offset in pixels to render this layer, usually 0 (IMPORTANT: this should be added to the LayerDef optional offset, so you should probably prefer using pxTotalOffsetY which contains the total offset value)


ldtk
visible: Bool

Layer instance visibility


ldtk
optionalRules: Array<Int>

An Array containing the UIDs of optional rules that were enabled in this specific layer instance.


ldtk
seed: Int

Random seed used for Auto-Layers rendering


ldtk
intGridVersion: Int

Incremented every time the IntGrid content changes through setIntGrid() or markIntGridChanged(). Rule runners reading this layer use it to know when to refresh their prefilter data.


ldtk
intGridDirtyLeft: Int

Bounds (inclusive cells) of the IntGrid changes made since clearIntGridDirtyRect() was last called, -1 when nothing is pending. LdtkRuleRunner uses them to recompute only the affected area.


ldtk
intGridDirtyTop: Int

ldtk
intGridDirtyRight: Int

ldtk
intGridDirtyBottom: Int

ldtk
intGridDirtySinceVersion: Int

Value of intGridVersion when the dirty rect started accumulating: a runner whose last compute saw at least this version can rely on the rect to cover every change it has not seen yet.


ldtk
ruleRunner: LdtkRuleRunner

Rule runner recomputing this layer's auto tiles at runtime (created on demand by LdtkRuleRunner.get())


ldtk
setIntGrid(cx: Int, cy: Int, value: Int): Void

Change an IntGrid value of this layer (0 = empty). Auto-layers reading this IntGrid are not recomputed automatically: call regenerateAutoLayerTiles() on them, or LdtkRuleRunner.refreshAutoLayersUsingSource().

Name Type
cx Int
cy Int
value Int

ldtk
markIntGridChanged(): Void

Call this after modifying intGrid directly (the whole layer is then considered changed)


ldtk
clearIntGridDirtyRect(): Void

Forget the pending IntGrid dirty rect. Called by LdtkRuleRunner.refreshAutoLayersUsingSource() once every auto-layer reading this IntGrid has been recomputed.


ldtk
regenerateAutoLayerTiles(?tilemap: Tilemap): Bool

Recompute autoLayerTiles from the current IntGrid with the LDtk rule engine (same results as the editor), then refresh ceramicLayer. If tilemap is given, its layers displaying this data are marked dirty. Returns false if this layer has no usable rules.

Name Type Default
tilemap Tilemap (optional)
Returns
Bool

ldtk
toString(): String
Returns
String

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

Private Members

ldtk
extendIntGridDirtyRect(left: Int, top: Int, right: Int, bottom: Int): Void
Name Type
left Int
top Int
right Int
bottom Int