LdtkLayerInstance
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
The Ceramic layer generated from this level
The LDtk level this layer instance belongs to
The related layer definition
Layer opacity as Float [0-1]
Grid-based width
Grid-based height
Total layer X pixel offset, including both instance and definition offsets.
Total layer Y pixel offset, including both instance and definition offsets.
The corresponding Tileset definition, if any.
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].
Entity instances (only on Entity layers)
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].
Unique layer instance identifier
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)
Reference to the UID of the level containing this layer instance
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)
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)
Layer instance visibility
An Array containing the UIDs of optional rules that were enabled in this specific layer instance.
Random seed used for Auto-Layers rendering
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.
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.
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.
Rule runner recomputing this layer's auto tiles at runtime (created on demand by LdtkRuleRunner.get())
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 |
Call this after modifying intGrid directly (the whole layer is then considered changed)
Forget the pending IntGrid dirty rect. Called by LdtkRuleRunner.refreshAutoLayersUsingSource() once every
auto-layer reading this IntGrid has been recomputed.
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 |
| Returns |
|---|
| String |
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
| Name | Type |
|---|---|
left |
Int |
top |
Int |
right |
Int |
bottom |
Int |