tiled-tmx-parser
TypeScript icon, indicating that this package has built-in type declarations

2.0.9 • Public • Published

Tiled TMX Parser

Loads tmx and tsx files created by the Tiled Map Editor. Works with both embedded and referenced tilesets.

https://www.mapeditor.org/

Examples

Load by URI

import {parse} from 'tiled-tmx-parser';

async function loadMap() {
    // Must be an absolute uri
    const map = await parse('http://{YOUR_SITE}/my-map.tmx');
}

Load by path

import {parse} from 'tiled-tmx-parser';

async function loadMap() {
    // Must be an absolute uri
    const map = await parse(path.join(__dirname, './maps/my-map.tmx');
}

API

import {parse} from 'tiled-tmx-parser';

async function loadMap() {
    // Must be an absolute uri
    const map = await parse(path.join(__dirname, './maps/my-map.tmx');
    const tileLayer = map.layers.find(x => x instanceof TileLayer) // as TileLayer;
    const firstTile = tileLayer.tileAt(0, 0);
    const firstObject = map.getObjectById(1);
    const firstTileInTileSet = map.getTileById(1);
    const firstTileSet = map.getTileSetByGid(1);
}

Options

Key Description DefaultValue
transformObjectProperties Whether or not to transform "object" custom properties into a reference of the object. If set to false, a number is used as the custom property. true

Notes

  • Does not support Base64 ZStandard compression
  • Does not support "Output Chunk Width/Height"
  • Does not currently support Group Layer

Package Sidebar

Install

npm i tiled-tmx-parser

Weekly Downloads

2

Version

2.0.9

License

MIT

Unpacked Size

60.9 kB

Total Files

75

Last publish

Collaborators

  • imallic