API reference

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

N

namespaceLdtk Functions

@codexo/exojs-ldtk / ldtk / stable

Free functions and constants exported from @codexo/exojs-ldtk.

9
props
5
methods
0
events
Overview

Free functions and constants exported from @codexo/exojs-ldtk. Import any of them directly, for example `import { createLdtkIntGridCellSource } from '@codexo/exojs-ldtk'`.

Functions5
Per-cell collision classification for a TileLayer converted from an LDtk IntGrid layer instance, or undefined when the layer carries no IntGrid data (not converted from an IntGrid layer instance, or unbounded). The classification is the value's LDtk-authored identifier, falling back to the raw integer as a string when the value definition declares none. Cells whose raw value is 0 (empty) classify as null. Distinct IntGrid values stay distinct strings: what they mean - solid, water, hazard - is the caller's to decide, and an unrecognised value is data, not an error. The result reads the layer's frozen IntGrid data, so it is stable for the lifetime of the layer and safe to hand to a consumer that samples it while building geometry. ts const geometry = buildTileCollisionGeometry(layer, { cells: createLdtkIntGridCellSource(layer) });
Look up the named/coloured LdtkIntGridValueDef at a tile coordinate on a TileLayer converted from an LDtk IntGrid layer instance. Returns undefined when the coordinate is out of bounds, the cell's raw value is 0 (empty), the raw value has no matching definition, or layer was not converted from an IntGrid layer instance (no IntGrid data attached via ldtkIntGridCsvProperty / ldtkIntGridValuesProperty). The underlying JSON-encoded CSV/value-defs properties are parsed once per layer and cached (see getParsedIntGridData) - safe to call from a hot path (e.g. per-cell or per-frame collision/classification checks).
isLdtkFieldEnumType(typeName: string): typeName
Whether a raw LDtk __type names an enum. Applies to an Array<T> element type as well - LDtk spells a list of enum values Array<LocalEnum.Name>.
Build the format-neutral world model for an LDtk document: one MapWorld per LDtk world, in document order. A single-world project - the overwhelmingly common shape - yields exactly one unnamed world. A multi-world project yields one per entry of worlds[], each named by its identifier, and they stay separate on purpose: LDtk worlds have independent coordinate spaces, so merging them would make MapWorld.bounds and MapWorld.getLevelsInBounds report overlaps that do not exist. MapLevel.index counts across the whole document, matching the flattened order import('./LdtkMap').LdtkMap.levels uses. Level metadata only: no layer payload is read, so this is safe to call on a document whose external levels have not been fetched.
Convert a raw LdtkData document into an LdtkMap containing one runtime TileMap per LDtk level. Tile layers (Tiles / AutoLayer) become renderable TileLayers. IntGrid layers become dimension-correct TileLayers - tile data is placed only when the layer carries autoLayerTiles. Entity layers become data-only ObjectLayers with entity position, size, and scalar field properties. Pass options.tilesets to populate tile data; omit it for structure-only conversion (useful in unit tests that do not need textures). Transparently handles both LDtk root shapes via getLdtkLevelEntries: single-world (data.levels) and multi-world (data.worlds[].levels) - in the latter case every converted level's TileMap.properties is additionally tagged with its owning world's iid under the reserved ldtkWorldIid key.
Constants9
LDTK_FLIP_NONE: 0
Flip-bit constants for LdtkTileData.f.
LDTK_FLIP_X: 1
LDTK_FLIP_XY: 3
LDTK_FLIP_Y: 2
Default immutable LDtk extension descriptor. Installs two asset types: - ldtkMapType - loader.load(ldtkMapType.asset('world.ldtk')) reads the .ldtk document, loads all referenced tileset images, and returns a fully assembled LdtkMap with one runtime import('@codexo/exojs-tilemap').TileMap per level. - ldtkProjectType - loader.load(ldtkProjectType.asset('world.ldtk')) returns the world layout and tileset atlases only, for games that load levels on demand. Depends on tilemapExtension so that snapshot construction always materialises the generic tilemap runtime before the LDtk adapter. Pass it to the application that should have it via ApplicationOptions.extensions.
ldtkIntGridCsvProperty: "ldtkIntGridCsv"
Reserved TileLayer.properties key holding the JSON-encoded raw IntGrid CSV array (readonly number[]) for a TileLayer converted from an LDtk IntGrid layer instance. Index = y * layer.width + x; 0 = empty. Prefer getLdtkIntGridValueAt over reading this directly.
ldtkIntGridValuesProperty: "ldtkIntGridValues"
Reserved TileLayer.properties key holding the JSON-encoded LdtkIntGridValueDef array for a TileLayer converted from an LDtk IntGrid layer instance - the raw-int → named/coloured mapping declared on the owning layer definition (data.defs.layers[].intGridValues). Prefer getLdtkIntGridValueAt over reading this directly.