API reference

Every public class, method, and event in @codexo/exojs. Generated from source.

C

classTileLayer

@codexo/exojs-tilemap / tilemap / stable

A generic, format-independent tile layer with chunk-first storage. Tile data is stored in fixed-size TileChunks indexed by signed chunk coordinates. For finite maps, only chunks that intersect the layer bounds exist. **Mutation must go through the layer's public APIs only.** `setTileAt` / `clearTileAt` validate coordinates, tileset references, and increment revision counters only when the stored value actually changes. Direct chunk mutation is not supported - the layer owns chunk storage and exposes only a ReadonlyTileChunk view. The layer is NOT a SceneNode - that integration lives in import('./TileLayerNode').TileLayerNode.

24
props
15
methods
0
events
Import
import { TileLayer } from '@codexo/exojs-tilemap'

A generic, format-independent tile layer with chunk-first storage.

Tile data is stored in fixed-size TileChunks indexed by signed chunk coordinates. For finite maps, only chunks that intersect the layer bounds exist.

**Mutation must go through the layer's public APIs only.** `setTileAt` / `clearTileAt` validate coordinates, tileset references, and increment revision counters only when the stored value actually changes. Direct chunk mutation is not supported - the layer owns chunk storage and exposes only a ReadonlyTileChunk view.

The layer is NOT a SceneNode - that integration lives in import('./TileLayerNode').TileLayerNode.

Constructors1
Methods15
Compute the range of chunk coordinates that intersect this layer, or null if the layer is unbounded (any signed chunk coordinate is valid).
clearRect(x: number, y: number, w: number, h: number): void
Clear a rectangular region.
clearTileAt(tx: number, ty: number): void
Clear (erase) the tile at the given coordinates. No-op if the cell is already empty.
countNonEmptyTiles(): number
Total number of non-empty tiles across all chunks. Walk is cheap for dense layers; sparse layers benefit from empty-chunk fast path.
destroy(): void
Destroy this layer: clear chunk storage and mark destroyed. Does NOT destroy tileset textures or external resources. Idempotent.
Get a readonly view of a chunk by signed chunk coordinates, or undefined if it does not exist (never been touched).
getRawTileAt(tx: number, ty: number): number
Get the raw packed tile word at (tx, ty). Returns 0 for empty or out-of-bounds.
Query a resolved tile at (tx, ty). Returns null for empty or out-of-bounds.
inBounds(tx: number, ty: number): boolean
Check whether a tile coordinate lies within the layer bounds. Always true for an unbounded layer.
Iterate over all loaded chunks in deterministic (cy, cx) ascending order. Returns readonly chunk views - callers cannot mutate storage.
pixelToTile(px: number, py: number): { tx: number; ty: number }
Convert a local pixel position to the tile coordinate that contains it. Uses floor, so a point exactly on a tile boundary maps to the tile. May return coordinates outside layer bounds.
Set a tile at the given tile coordinates. No-op if the effective value is unchanged.
Iterate non-empty tiles within a rectangular region in row-major order. Yields (tx, ty, resolvedTile) tuples. Skips empty cells.
tileToPixel(tx: number, ty: number): { x: number; y: number }
Convert a tile coordinate to the pixel position of its top-left corner in the layer's local space.
Properties24
chunkHeight: number
Chunk height (tiles).
chunkWidth: number
Chunk width (tiles).
class: string
Layer class/type string (Tiled class; may be empty).
height: number | undefined
Height in tiles, or undefined if unbounded.
id: number
Stable unique ID within the map.
name: string
Display name (may not be unique).
offsetX: number
Horizontal pixel offset (mutable).
offsetY: number
Vertical pixel offset (mutable).
opacity: number
Opacity 0..1 (mutable).
parallaxScale: number
Uniform scale applied around the layer origin during parallax rendering.
parallaxX: number
Parallax scroll factor on the X axis. 1.0 = full camera speed, 0.5 = half speed, 0.0 = stationary.
parallaxY: number
Parallax scroll factor on the Y axis. 1.0 = full camera speed, 0.5 = half speed, 0.0 = stationary.
tileHeight: number
Tile height in pixels.
tileWidth: number
Tile width in pixels.
tintColor: null | number
Multiplicative layer tint as 0xRRGGBB, or null for no tint.
visible: boolean
Visibility flag (mutable).
width: number | undefined
Width in tiles, or undefined if unbounded.
bounded: boolean
true if this layer has a fixed width/height; false if unbounded.
destroyed: boolean
Whether the layer has been destroyed.
pixelHeight: number | undefined
Pixel height, or undefined if unbounded.
pixelWidth: number | undefined
Pixel width, or undefined if unbounded.
revision: number
Monotonic layer revision counter. Increments on every cell mutation that changes a stored value. No-op writes and failed mutations do NOT increment.
Source