# tmx-tiledmap

> Parser for Tiled map editor *.tmx files.

Latest version **1.2.1** (published 2020-07-20) · MIT license · 0 weekly downloads

## Install

```sh
npm install tmx-tiledmap
pnpm add tmx-tiledmap
yarn add tmx-tiledmap
bun add tmx-tiledmap
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.2.1 |
| Published | 2020-07-20 |
| First published | 2019-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=10.21.0 |
| Dependencies | 2 |
| Unpacked size | 68.1 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 12 |
| Maintainers | praghus |
| Keywords | tmx, tiledmap, parser |

## Links

- npm: https://www.npmjs.com/package/tmx-tiledmap
- Repository: https://github.com/praghus/tmx-tiledmap
- Homepage: https://praghus.github.io/tmx-tiledmap
- Issues: https://github.com/praghus/tmx-tiledmap/issues
- npm.io page: https://npm.io/package/tmx-tiledmap

## Dependencies (2)

- [zlib](https://npm.io/package/zlib.md) ^1.0.5
- [xml2js](https://npm.io/package/xml2js.md) ^0.4.22

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 1.2.1 (latest) — 2020-07-20
- 1.2.0 — 2020-07-01
- 1.1.8 — 2020-05-24
- 1.1.7 — 2019-11-13
- 1.1.6 — 2019-09-23
- 1.1.5 — 2019-09-17
- 1.1.3 — 2019-09-17
- 1.1.1 — 2019-09-17
- 1.0.4 — 2019-09-17
- 1.0.3 — 2019-06-16
- 1.0.2 — 2019-06-16
- 1.0.1 — 2019-06-16

## README

# tmx-tiledmap [![npm version](https://badge.fury.io/js/tmx-tiledmap.svg)](//npmjs.com/package/tmx-tiledmap) [![Build Status](https://travis-ci.org/praghus/tmx-tiledmap.svg?branch=master)](https://travis-ci.org/praghus/tmx-tiledmap)

Parser for [Tiled Map Editor](http://www.mapeditor.org/) *.tmx files.

## Installation

```sh
npm install tmx-tiledmap
```

or using yarn

```sh
yarn add tmx-tiledmap
```
## Usage

The basic implementation:

```js
// TMX file loaded using webpack 'url-loader' (can be either a string or URL encoded data).
import tmxFile from '../assets/levels/map.tmx'
import { tmx } from 'tmx-tiledmap'

tmx(tmxFile).then((data) => {
    console.info(data)
})
```

webpack.config.js

```js
module.exports = {
    module: {
        rules: [
            test: /\.tmx$/,
            include: path.join(process.cwd(), 'src/assets/levels'),
            use: 'url-loader'
        ]
    }
}
```
### Important
Parser only supports embedded tilesets. At the moment, external tilesets are not supported!


## Documentation

Example parsed data

```js
{
    tiledversion: "1.2.4",
    tilewidth: 16,
    tileheight: 16,
    version: 1.2,
    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, …],
        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: "../images/tiles.png", width: 512, height: 512},
        name: "tiles",
        tilecount: 1024,
        tilewidth: 16,
        tileheight: 16,
        tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
    }, {
        …
    }]
}
```

## License

[MIT licensed](./LICENSE).

---
_Source: https://npm.io/package/tmx-tiledmap · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
