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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
file |
unknown |
tiledMapOptions |
TiledMapOptions |
Returns
Section titled “Returns”Example
Section titled “Example”const map = readTiledMap(field, { tileSets: { grass } }); map.layers.map((layer) => <TileMapLayer key={layer.id} {...layer} />);