Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

readTiledMap

readTiledMap(file, tiledMapOptions): TiledMap

Reads a Tiled map, a .tmj import: its tile layers ready to spread on a TileMapLayer, its object layers, so spawns, doors and triggers placed in Tiled reach the game, and the rectangle it covers. Tiled’s (0, 0) stands at position. Orthogonal maps alone; flips, tile animations, external .tsj tile sets, several firstgids and an infinite map’s chunks are read. Call it at module scope, beside the tile sets, so it reads the file once.

Parameter Type
file unknown
tiledMapOptions TiledMapOptions

TiledMap

const map = readTiledMap(field, { tileSets: { grass } });
map.layers.map((layer) => <TileMapLayer key={layer.id} {...layer} />);