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

2.4.0 • Public • Published

parse-tmx

Apache-2.0 licensed NPM version NPM downloads NPM Unpacked Size (with version)

Inspired by tmx-map-parser. A parser for Tiled Map Editor *.tmx files.

Table of Contents


pnpm i parse-tmx

We highly recommend you take a look at the documentation to level up.

Usage

The basic implementation:

import { parseTmx } from "parse-tmx";
// The *.tmx file can be loaded as a string or URL encoded data
import map from "map.tmx";

// Translates the tile flips in the layer data (default: false)
const translateFlips = true;

const loadMap = async () => {
  const data = await parseTmx(map, translateFlips);
  ...
};

Example data

TMX Map Format documentation

{
    tiledversion: "1.8.0",
    tilewidth: 16,
    tileheight: 16,
    version: 1.8,
    width: 512,
    height: 128,
    infinite: 0,
    nextlayerid: 5,
    nextobjectid: 165,
    orientation: "orthogonal",
    renderorder: "right-down",
    properties: {
        property1: 'value',
        property2: 0.5
    },
    layers: [{
        id: 1,
        name: "layer name",
        type: "layer",
        visible: 1,
        data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, ],
        // When the translateFlips parameter is enabled
        flips: [
            {H: false, V: false, D: false},
            {H: true, V: false, D: true},
            {H: false, V: false, D: false},
            {}
        ],
        width: 512,
        height: 128,
        opacity: 0.77,
        properties: {
           property1: 'value',
           property2: false
        }
    }, {
        id: 2,
        name: "objects",
        type: "objectgroup",
        visible: 1,
        objects: [{}, {}, {}],
        properties: {
           property1: 'value',
           property2: false
        }
    }, {}],
    tilesets: [{
        columns: 32,
        firstgid: 1,
        image: {source: "tiles.png", width: 512, height: 512},
        name: "tiles",
        tilecount: 1024,
        tilewidth: 16,
        tileheight: 16,
        tiles: [{}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
    }, {}]
}

This project is licensed under the Apache-2.0 license.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
2.4.00latest

Version History

VersionDownloads (Last 7 Days)Published
2.4.00
2.3.061
2.2.19
2.1.01
2.0.00
1.42.31
1.42.21
1.42.11
1.42.01
1.41.00
1.40.00
1.39.00
1.38.10
1.37.10
1.37.00
1.36.00
1.35.00
1.34.00
1.33.00
1.32.00
1.31.00
1.30.00
1.29.20
1.29.10
1.29.00
1.28.10
1.28.00
1.27.00
1.26.00
1.25.00
1.24.20
1.24.10
1.24.00
1.23.00
1.22.01
1.21.50
1.21.40
1.21.30
1.21.20
1.21.10
1.21.00
1.20.20
1.20.10
1.20.00
1.19.00
1.18.00
1.17.00
1.16.00
1.15.00
1.14.00
1.13.00
1.12.00
1.11.20
1.11.10
1.11.00
1.10.00
1.9.10
1.9.00
1.8.20
1.7.10
1.7.00
1.2.00
1.1.20
1.1.10
1.1.00
1.0.300
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.210
1.0.100

Package Sidebar

Install

npm i parse-tmx

Weekly Downloads

25

Version

2.4.0

License

Apache-2.0

Unpacked Size

1.48 MB

Total Files

5

Last publish

Collaborators

  • q16solver