TilemapLayerData

Entitytracker.Modelceramic.TilemapLayerData (Class)

Data model representing a single layer within a tilemap.

TilemapLayerData holds all the information needed to render and interact with a tilemap layer, including tile indices, dimensions, positioning, and visual properties. This is a reactive Model that notifies observers when properties change, allowing TilemapLayer visuals to update automatically.

Features

  • Tile Storage: Holds tile indices referencing tilesets via global IDs (GIDs)
  • Auto-tiling Support: Can store both original and computed tiles after auto-tiling
  • Per-tile Properties: Supports per-tile alpha and offset values
  • Layer Properties: Position, size, visibility, opacity, and blending modes
  • Reactive Updates: Extends Model for automatic change notifications

Usage Example

// Create a new layer data
var layer = new TilemapLayerData();
layer.name = 'collision';
layer.grid(20, 15); // 20x15 tiles
layer.tileSize(32, 32); // 32x32 pixel tiles

// Set tiles (array of TilemapTile values)
var tiles = [];
for (i in 0...300) {
    tiles.push(i == 150 ? 1 : 0); // Single tile in center
}
layer.tiles = tiles;

// Configure visual properties
layer.opacity = 0.8;
layer.color = Color.RED;

Instance Members

ldtk
ldtkLayer: LdtkLayerInstance

Reference to the source LDtk layer instance when this layer was imported from LDtk. Provides access to additional LDtk-specific data and properties.


tilemap
name: String

The name of the layer


tilemap
x: Int

The x position of the layer in tiles


tilemap
y: Int

The y position of the layer in tiles


tilemap
columns: Int

The width of the layer in tiles


tilemap
rows: Int

The height of the layer in tiles


tilemap
opacity: Float

The opacity of the layer


tilemap
visible: Bool

Whether this layer is visible or not


tilemap
offsetX: Int

X offset for this layer in points.


tilemap
offsetY: Int

Y offset for this layer in points.


tilemap
explicitDepth: Null<Float>

Explicit depth, or null of that should be computed by Tilemap instead


tilemap
blending: Blending

Tile default blending


tilemap
color: Color

Tile default (tint) color


tilemap
extraBlending: Blending

Extra tile default blending


tilemap
extraOpacity: Float

Extra tile default alpha


Tiles


tilemap
tilesAlpha: ReadOnlyArray<Float>

Per-tile alpha, or null if there is no custom alpha per tile


tilemap
tilesOffsetX: ReadOnlyArray<Int>

Per-tile x offset in pixels, or null if there is no offset


tilemap
tilesOffsetY: ReadOnlyArray<Int>

Per-tile y offset in pixels, or null if there is no offset


tilemap
computedTiles: ReadOnlyArray<TilemapTile>

Computed tiles, after applying auto-tiling (if any). Will be null if no auto-tiling is used.


tilemap
computedTilesAlpha: ReadOnlyArray<Float>

Per-computed tile alpha, or null if there is no custom alpha per computed tile


tilemap
computedTilesOffsetX: ReadOnlyArray<Int>

Per-computed tile x offset in pixels, or null if there is no offset per computed tile


tilemap
computedTilesOffsetY: ReadOnlyArray<Int>

Per-computed tile y offset in pixels, or null if there is no offset per computed tile


tilemap
hasTiles: Bool

Is true if this layer has tiles. Some layers don't have tile and don't need to be rendered with tilemap layer quads, but are still available as containers to add custom objects (like LDtk entities).


tilemap
shouldRenderTiles: Bool

Is true (default) if this layer should have its tiles rendered (if any).


tilemap
tileWidth: Int

The width of a tile in this layer


tilemap
tileHeight: Int

The height of a tile in this layer


tilemap
invalidateLdtkLayer(): Void

tilemap
invalidateName(): Void

tilemap
invalidateX(): Void

tilemap
invalidateY(): Void

tilemap
invalidateColumns(): Void

tilemap
invalidateRows(): Void

tilemap
invalidateOpacity(): Void

tilemap
invalidateVisible(): Void

tilemap
invalidateOffsetX(): Void

tilemap
invalidateOffsetY(): Void

tilemap
invalidateExplicitDepth(): Void

tilemap
invalidateBlending(): Void

tilemap
invalidateColor(): Void

tilemap
invalidateExtraBlending(): Void

tilemap
invalidateExtraOpacity(): Void

tilemap
invalidateTiles(): Void

tilemap
invalidateTilesAlpha(): Void

tilemap
invalidateTilesOffsetX(): Void

tilemap
invalidateTilesOffsetY(): Void

tilemap
invalidateComputedTiles(): Void

tilemap
invalidateComputedTilesAlpha(): Void

tilemap
invalidateComputedTilesOffsetX(): Void

tilemap
invalidateComputedTilesOffsetY(): Void

tilemap
invalidateHasTiles(): Void

tilemap
invalidateShouldRenderTiles(): Void

tilemap
invalidateTileWidth(): Void

tilemap
invalidateTileHeight(): Void

tilemap
grid(columns: Int, rows: Int): Void

A shorthand to set columns and rows

Name Type Description
columns Int *
rows Int

tilemap
pos(x: Int, y: Int): Void

A shorthand to set x and y

Name Type
x Int
y Int

tilemap
offset(offsetX: Int, offsetY: Int): Void

A shorthand to set offsetX and offsetY

Name Type
offsetX Int
offsetY Int

tilemap
tileSize(tileWidth: Int, tileHeight: Int): Void

A shorthand to set tileWidth and tileHeight

Name Type Description
tileWidth Int *
tileHeight Int

tilemap
indexFromColumnAndRow(column: Int, row: Int): Int

Converts column and row coordinates to a tile index.

Name Type Description
column Int The column position (0-based)
row Int The row position (0-based)
Returns Description
Int The tile index in the flat tiles array

tilemap
tileByColumnAndRow(column: Int, row: Int): TilemapTile

Retrieves the tile at the specified column and row position from the tiles array.

Name Type Description
column Int The column position (0-based)
row Int The row position (0-based)
Returns Description
TilemapTile The TilemapTile at the position

tilemap
computedTileByColumnAndRow(column: Int, row: Int): TilemapTile

Retrieves the computed tile at the specified column and row position. Used when auto-tiling has been applied to get the final tile value.

Name Type Description
column Int The column position (0-based)
row Int The row position (0-based)
Returns Description
TilemapTile The computed TilemapTile at the position

tilemap
columnAtIndex(index: Int): Int

Gets the column position from a tile index.

Name Type Description
index Int The tile index in the flat array
Returns Description
Int The column position (0-based)

tilemap
rowAtIndex(index: Int): Int

Gets the row position from a tile index.

Name Type Description
index Int The tile index in the flat array
Returns Description
Int The row position (0-based)

tilemap
new(): Void

Private Members

tilemap
unobservedLdtkLayer: LdtkLayerInstance

tilemap
unobservedName: String

tilemap
unobservedX: Int

tilemap
unobservedY: Int

tilemap
unobservedColumns: Int

tilemap
unobservedRows: Int

tilemap
unobservedOpacity: Float

tilemap
unobservedVisible: Bool

tilemap
unobservedOffsetX: Int

tilemap
unobservedOffsetY: Int

tilemap
unobservedExplicitDepth: Null<Float>

tilemap
unobservedBlending: Blending

tilemap
unobservedColor: Color

tilemap
unobservedExtraBlending: Blending

tilemap
unobservedExtraOpacity: Float

tilemap
unobservedTiles: ReadOnlyArray<TilemapTile>

tilemap
unobservedTilesAlpha: ReadOnlyArray<Float>

tilemap
unobservedTilesOffsetX: ReadOnlyArray<Int>

tilemap
unobservedTilesOffsetY: ReadOnlyArray<Int>

tilemap
unobservedComputedTiles: ReadOnlyArray<TilemapTile>

tilemap
unobservedComputedTilesAlpha: ReadOnlyArray<Float>

tilemap
unobservedComputedTilesOffsetX: ReadOnlyArray<Int>

tilemap
unobservedComputedTilesOffsetY: ReadOnlyArray<Int>

tilemap
unobservedHasTiles: Bool

tilemap
unobservedShouldRenderTiles: Bool

tilemap
unobservedTileWidth: Int

tilemap
unobservedTileHeight: Int

tilemap
emitLdtkLayerChange(current: LdtkLayerInstance, previous: LdtkLayerInstance): Void

Event when ldtkLayer field changes.

Name Type
current LdtkLayerInstance
previous LdtkLayerInstance

tilemap
emitNameChange(current: String, previous: String): Void

Event when name field changes.

Name Type
current String
previous String

tilemap
emitXChange(current: Int, previous: Int): Void

Event when x field changes.

Name Type
current Int
previous Int

tilemap
emitYChange(current: Int, previous: Int): Void

Event when y field changes.

Name Type
current Int
previous Int

tilemap
emitColumnsChange(current: Int, previous: Int): Void

Event when columns field changes.

Name Type
current Int
previous Int

tilemap
emitRowsChange(current: Int, previous: Int): Void

Event when rows field changes.

Name Type
current Int
previous Int

tilemap
emitOpacityChange(current: Float, previous: Float): Void

Event when opacity field changes.

Name Type
current Float
previous Float

tilemap
emitVisibleChange(current: Bool, previous: Bool): Void

Event when visible field changes.

Name Type
current Bool
previous Bool

tilemap
emitOffsetXChange(current: Int, previous: Int): Void

Event when offsetX field changes.

Name Type
current Int
previous Int

tilemap
emitOffsetYChange(current: Int, previous: Int): Void

Event when offsetY field changes.

Name Type
current Int
previous Int

tilemap
emitExplicitDepthChange(current: Null<Float>, previous: Null<Float>): Void

Event when explicitDepth field changes.

Name Type
current Null<Float>
previous Null<Float>

tilemap
emitBlendingChange(current: Blending, previous: Blending): Void

Event when blending field changes.

Name Type
current Blending
previous Blending

tilemap
emitColorChange(current: Color, previous: Color): Void

Event when color field changes.

Name Type
current Color
previous Color

tilemap
emitExtraBlendingChange(current: Blending, previous: Blending): Void

Event when extraBlending field changes.

Name Type
current Blending
previous Blending

tilemap
emitExtraOpacityChange(current: Float, previous: Float): Void

Event when extraOpacity field changes.

Name Type
current Float
previous Float

tilemap
emitTilesChange(current: ReadOnlyArray<TilemapTile>, previous: ReadOnlyArray<TilemapTile>): Void

Event when tiles field changes.

Name Type
current ReadOnlyArray<TilemapTile>
previous ReadOnlyArray<TilemapTile>

tilemap
emitTilesAlphaChange(current: ReadOnlyArray<Float>, previous: ReadOnlyArray<Float>): Void

Event when tilesAlpha field changes.

Name Type
current ReadOnlyArray<Float>
previous ReadOnlyArray<Float>

tilemap
emitTilesOffsetXChange(current: ReadOnlyArray<Int>, previous: ReadOnlyArray<Int>): Void

Event when tilesOffsetX field changes.

Name Type
current ReadOnlyArray<Int>
previous ReadOnlyArray<Int>

tilemap
emitTilesOffsetYChange(current: ReadOnlyArray<Int>, previous: ReadOnlyArray<Int>): Void

Event when tilesOffsetY field changes.

Name Type
current ReadOnlyArray<Int>
previous ReadOnlyArray<Int>

tilemap
emitComputedTilesChange(current: ReadOnlyArray<TilemapTile>, previous: ReadOnlyArray<TilemapTile>): Void

Event when computedTiles field changes.

Name Type
current ReadOnlyArray<TilemapTile>
previous ReadOnlyArray<TilemapTile>

tilemap
emitComputedTilesAlphaChange(current: ReadOnlyArray<Float>, previous: ReadOnlyArray<Float>): Void

Event when computedTilesAlpha field changes.

Name Type
current ReadOnlyArray<Float>
previous ReadOnlyArray<Float>

tilemap
emitComputedTilesOffsetXChange(current: ReadOnlyArray<Int>, previous: ReadOnlyArray<Int>): Void

Event when computedTilesOffsetX field changes.

Name Type
current ReadOnlyArray<Int>
previous ReadOnlyArray<Int>

tilemap
emitComputedTilesOffsetYChange(current: ReadOnlyArray<Int>, previous: ReadOnlyArray<Int>): Void

Event when computedTilesOffsetY field changes.

Name Type
current ReadOnlyArray<Int>
previous ReadOnlyArray<Int>

tilemap
emitHasTilesChange(current: Bool, previous: Bool): Void

Event when hasTiles field changes.

Name Type
current Bool
previous Bool

tilemap
emitShouldRenderTilesChange(current: Bool, previous: Bool): Void

Event when shouldRenderTiles field changes.

Name Type
current Bool
previous Bool

tilemap
emitTileWidthChange(current: Int, previous: Int): Void

Event when tileWidth field changes.

Name Type
current Int
previous Int

tilemap
emitTileHeightChange(current: Int, previous: Int): Void

Event when tileHeight field changes.

Name Type
current Int
previous Int

Metadata

Name Parameters
:build tracker.macros.EventsMacro.build()
:autoBuild tracker.macros.EventsMacro.build()
:build ceramic.macros.EntityMacro.buildForCompletion()
:autoBuild ceramic.macros.EntityMacro.buildForCompletion()
:build tracker.macros.ObservableMacro.build()
:autoBuild tracker.macros.ObservableMacro.build()
:build tracker.macros.SerializableMacro.build()
:autoBuild tracker.macros.SerializableMacro.build()