TilemapLayer

EntityVisualceramic.TilemapLayer (Class)

Visual representation of a single layer within a tilemap.

A TilemapLayer renders tiles from a TilemapLayerData structure, handling tile placement, clipping, rendering order, and optional collision detection. Each layer consists of a grid of TilemapQuad instances that display individual tiles from the tilemap's tilesets.

Features

  • Tile Rendering: Automatically creates and manages TilemapQuad instances for visible tiles
  • Clipping Support: Can render only a subset of tiles based on clip bounds
  • Render Order: Respects the tilemap's render order (RIGHT_DOWN, LEFT_UP, etc.)
  • Tile Filtering: Supports applying visual filters to all tiles in the layer
  • Collision Detection: When using the arcade physics plugin, supports tile-based collisions
  • Tile Transformations: Handles horizontal/vertical/diagonal flipping of tiles

Usage Example

// Layers are typically created automatically by Tilemap
var tilemap = new Tilemap();
tilemap.tilemapData = myTilemapData;

// Access a specific layer
var layer = tilemap.layer('collision');

// Apply a filter to all tiles in the layer
var blur = new Filter();
blur.shader = assets.shader('blur');
layer.tilesFilter = blur;

// Configure collision (requires arcade plugin)
layer.checkCollision(true, true); // Enable up/down and left/right collisions

Instance Members

arcade
checkCollisionUp: Bool

If this layer is collidable, this determines if it will collide up. (when a body is going downward torward the tile)


arcade
checkCollisionDown: Bool

If this layer is collidable, this determines if it will collide down. (when a body is going upward toward a tile)


arcade
checkCollisionLeft: Bool

If this layer is collidable, this determines if it will collide left. (when a body is going rightward toward the tile)


arcade
checkCollisionRight: Bool

If this layer is collidable, this determines if it will collide right. (when a body is going leftward toward the tile)


arcade
checkCollisionWithComputedTiles: Bool

If this layer is collidable, this determines if it will collide using tiles or computedTiles


arcade
checkCollisionValues: Array<Int>

If this layer is collidable, it collides with any tiles that have a value != 0, unless checkCollisionValues is provided. In that case, it will collide when matching any value of the array.


arcade
collidable: Bool

Internal flag used when walking through layers


arcade
checkCollision(upDown: Bool, rightLeft: Bool): Void

Shorthand to set checkCollisionUp, checkCollisionRight, checkCollisionDown, checkCollisionLeft

Name Type
upDown Bool
rightLeft Bool

tilemap
tilemap: Tilemap

The parent tilemap that owns this layer. Set automatically when the layer is created by a Tilemap.


tilemap
layerData: TilemapLayerData

The layer data that defines the tiles and properties for this layer. Changing this will trigger a complete re-render of the layer.


tilemap
tileScale: Float

Scale factor applied to all tiles in this layer. Default is 1.0 (no scaling). Useful for creating zoom effects or different tile sizes.


tilemap
tileQuads: Array<TilemapQuad>

Array of TilemapQuad instances representing visible tiles in this layer. This array is automatically managed and updated when the layer re-renders. Use tileQuadByIndex() or tileQuadByColumnAndRow() to access specific tiles.


tilemap
tilesColor: Color

Color tint applied to all tiles in this layer. This is multiplied with the layer's base color from layerData. Default is WHITE (no tint).


tilemap
destroyTilesFilterOnRemove: Bool

If true, removing (assign null) or replacing a tilesFilter will destroy it. Note that a tilesFilter will be destroyed if assigned when (parent) layer is destroyed, regardless of this setting.


tilemap
autoSizeTilesFilter: Bool

Set to false if you need to assign a tiles filter but want to keep control on how it is layouted (size, position...)


tilemap
tilesFilter: Filter

A filter that will be applied to every tile of this layer. If autoSizeTilesFilter is true (default), filter size will be set to layer content size. Existing filter is automatically destroyed if tilesFilter is set to null or the layer destroyed, unless you set destroyTilesFilterOnRemove to false.


tilemap
computeContent(): Void

Computes the visual content of this layer based on the current layer data. This method is called automatically when contentDirty is true. It calculates layer dimensions and generates/updates all tile quads.


tilemap
tileQuadByColumnAndRow(column: Int, row: Int): TilemapQuad

Retrieves the TilemapQuad at the specified column and row position.

Name Type Description
column Int The column index (0-based)
row Int The row index (0-based)
Returns Description
TilemapQuad The TilemapQuad at the position, or null if no tile exists there

tilemap
tileQuadByIndex(index: Int): TilemapQuad

Retrieves the TilemapQuad at the specified tile index.

Name Type Description
index Int The tile index in the layer's tile array
Returns Description
TilemapQuad The TilemapQuad at the index, or null if no tile exists there

tilemap
surroundingTileQuads(left: Float, top: Float, right: Float, bottom: Float, ?result: Array<TilemapQuad>): Array<TilemapQuad>

Retrieve surrounding tile quads (that could collide within the given area). The area is relative to this layer and does not take into account any offset or layer position.

Name Type Default Description
left Float *
top Float *
right Float *
bottom Float *
result Array<TilemapQuad> (optional) *
Returns Description
Array<TilemapQuad> Array

tilemap
new(): Void

Private Members

tilemap
tileQuadMapping: IntIntMap

Internal mapping to retrieve an existing tileQuad from its tile index. Maps from tile index to array position in tileQuads (1-based).


tilemap
emitTileQuadsChange(): Void

Event emitted when the tile quads array changes. This happens when tiles are added, removed, or when the layer is re-rendered.


tilemap
clearArcadeTiles(): Void

tilemap
computePosAndSize(): Void

Computes and sets the position and size of this layer based on layer data. Takes into account tile dimensions and layer offsets.


tilemap
computeTileQuads(tilemap: Tilemap, tilemapData: TilemapData): Void

Generates and updates TilemapQuad instances for all visible tiles in this layer. Handles tile clipping, render order, transformations, and pooling of quad instances.

Name Type Description
tilemap Tilemap The parent tilemap
tilemapData TilemapData The tilemap data containing tileset information

Metadata

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