API reference

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

C

classTileMap

@codexo/exojs-tilemap / tilemap / stable

A generic, format-independent tile map. Owns a finite grid of TileLayers and a shared set of TileSets. Tile data is stored in compact chunked arrays - no per-tile heap objects. The map does NOT own tileset textures (those are Loader-owned) and does NOT own SceneNode children - see import('./TileMapNode').TileMapNode, which owns those. Multiple tilesets are supported: each cell stores a packed tileset index and local tile ID, so different tilesets may have different tile dimensions.

21
props
21
methods
0
events
Import
import { TileMap } from '@codexo/exojs-tilemap'

A generic, format-independent tile map.

Owns a finite grid of TileLayers and a shared set of TileSets. Tile data is stored in compact chunked arrays - no per-tile heap objects.

The map does NOT own tileset textures (those are Loader-owned) and does NOT own SceneNode children - see import('./TileMapNode').TileMapNode, which owns those.

Multiple tilesets are supported: each cell stores a packed tileset index and local tile ID, so different tilesets may have different tile dimensions.

Constructors1
Methods21
Add an image layer after construction. Appended to both imageLayers and the end of renderableLayers's document order.
clearTileAt(layerId: number, tx: number, ty: number): void
Clear a tile on a given layer at tile coordinates. Convenience for map.getTileLayerById(id)?.clearTileAt(tx, ty).
Create a new TileMapView that groups this map's layers into independently placeable band / layer scene nodes for interleaving application actors between tile layers. Each call returns a fresh, independent view - the map does **not** cache a single global view, so multiple coexisting views of the same map are allowed. The view references this map but never owns it: destroying the view frees only its generated layer/band nodes - never the map, its layers, tileset textures, or any application actors.
destroy(): void
Destroy the map and all owned layers and chunk storage. Is idempotent. Does NOT destroy tileset textures (Loader-owned) or any SceneNodes (those do not exist yet in this slice).
Get an image layer by name (first match in insertion order), or undefined.
Get an object layer by name (first match in insertion order), or undefined. Supply an ObjectSchema type argument S to obtain a typed view of the layer - getObjectLayer<LevelObjects>('Entities') returns an ObjectLayer<LevelObjects> whose ObjectLayer.byType / ObjectLayer.where accessors narrow properties. The schema is a static developer promise only; no runtime validation is performed and the call remains fully back-compatible when omitted.
Get an object layer by ID. Supply an ObjectSchema type argument S to obtain a typed view of the layer, as with getObjectLayer.
Get a resolved tile from a given layer at tile coordinates. Convenience for map.getTileLayerById(id)?.getTileAt(tx, ty). Returns null for an empty cell, out-of-bounds, or missing layer.
pixelToTile(px: number, py: number): { tx: number; ty: number }
Convert a pixel position in map-local space to the tile coordinate that contains it. Uses floor. May return coordinates outside map bounds.
removeImageLayer(id: number): boolean
Remove an image layer by ID. Spliced out of renderableLayers's document order.
removeLayer(id: number): boolean
Remove a layer by ID. The layer is destroyed and spliced out of renderableLayers's document order.
removeObjectLayer(id: number): boolean
Remove an object layer by ID.
Set a tile on a given layer at tile coordinates. Convenience for map.getTileLayerById(id)?.setTileAt(tx, ty, tile).
tileToPixel(tx: number, ty: number): { x: number; y: number }
Convert a tile coordinate to the pixel position of its top-left corner in map-local space (ignoring layer offsets).
Properties21
backgroundColor: null | number
Map background colour as 0xRRGGBB, or null. Informational.
chunkHeight: number
Default chunk height for layers.
chunkWidth: number
Default chunk width for layers.
class: string
Map class/type string (Tiled class; may be empty).
height: number | undefined
Map height in tiles, or undefined if unbounded.
name: string
Map name (debug).
renderOrder: string
Tile draw order (Tiled renderorder). Informational.
tileHeight: number
Tile height in pixels.
tileWidth: number
Tile width in pixels.
width: number | undefined
Map width in tiles, or undefined if unbounded.
bounded: boolean
true if this map has a fixed width/height; false if unbounded.
destroyed: boolean
Whether the map has been destroyed.
pixelHeight: number | undefined
Pixel height, or undefined if unbounded.
pixelWidth: number | undefined
Pixel width, or undefined if unbounded.
Tile and image layers combined into a single document order (see TileMapOptions.documentOrder), maintained live as membership changes. Reflects addLayer / addImageLayer / removeLayer / removeImageLayer calls made after construction. Holds instance references, so entries stay correct even when a tile layer and an image layer share an id in a fallback-ordered map. Object layers are data-only and never appear here.
revision: number
Monotonic map revision counter. Increments on structural changes only (add/remove layer, add tileset). Cell mutations are tracked per-chunk and per-layer; the renderer reads chunk-level revisions directly.
Source