parse-tmx 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +125 -125
- package/dist/index.d.ts +147 -153
- package/dist/index.js +58261 -43236
- package/package.json +13 -13
package/README.md
CHANGED
|
@@ -1,125 +1,125 @@
|
|
|
1
|
-
# parse-tmx
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
[
|
|
1
|
+
# parse-tmx
|
|
2
|
+
|
|
3
|
+
[![Apache-2.0 licensed][badge-license]][url-license]
|
|
4
|
+
[![NPM version][badge-npm-version]][url-npm]
|
|
5
|
+
[![NPM downloads][badge-npm-downloads]][url-npm]
|
|
6
|
+
[![NPM Unpacked Size (with version)][badge-npm-unpacked-size]][url-npm]
|
|
7
|
+
|
|
8
|
+
Inspired by [tmx-map-parser](https://github.com/praghus/tmx-map-parser).
|
|
9
|
+
A parser for [Tiled Map Editor](http://www.mapeditor.org/) \*.tmx files.
|
|
10
|
+
|
|
11
|
+
### Table of Contents
|
|
12
|
+
|
|
13
|
+
- 🚀 [Getting Started](#getting-started)
|
|
14
|
+
- 📖 [Documentation](#documentation)
|
|
15
|
+
- ⚖️ [License](#license)
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## <a name="getting-started">🚀 Getting Started</a>
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
pnpm i parse-tmx
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## <a name="documentation">📖 Documentation</a>
|
|
26
|
+
|
|
27
|
+
We highly recommend you take a look at the [documentation](https://esposter.com/docs/modules/parse_tmx.html) to level up.
|
|
28
|
+
|
|
29
|
+
### Usage
|
|
30
|
+
|
|
31
|
+
The basic implementation:
|
|
32
|
+
|
|
33
|
+
```ts
|
|
34
|
+
import { parseTmx } from "parse-tmx";
|
|
35
|
+
// The *.tmx file can be loaded as a string or URL encoded data
|
|
36
|
+
import map from "map.tmx";
|
|
37
|
+
|
|
38
|
+
// Translates the tile flips in the layer data (default: false)
|
|
39
|
+
const translateFlips = true;
|
|
40
|
+
|
|
41
|
+
const loadMap = async () => {
|
|
42
|
+
const data = await parseTmx(map, translateFlips);
|
|
43
|
+
...
|
|
44
|
+
};
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Example data
|
|
48
|
+
|
|
49
|
+
[TMX Map Format documentation](https://doc.mapeditor.org/en/stable/reference/tmx-map-format/)
|
|
50
|
+
|
|
51
|
+
```js
|
|
52
|
+
{
|
|
53
|
+
tiledversion: "1.8.0",
|
|
54
|
+
tilewidth: 16,
|
|
55
|
+
tileheight: 16,
|
|
56
|
+
version: 1.8,
|
|
57
|
+
width: 512,
|
|
58
|
+
height: 128,
|
|
59
|
+
infinite: 0,
|
|
60
|
+
nextlayerid: 5,
|
|
61
|
+
nextobjectid: 165,
|
|
62
|
+
orientation: "orthogonal",
|
|
63
|
+
renderorder: "right-down",
|
|
64
|
+
properties: {
|
|
65
|
+
property1: 'value',
|
|
66
|
+
property2: 0.5
|
|
67
|
+
},
|
|
68
|
+
layers: [{
|
|
69
|
+
id: 1,
|
|
70
|
+
name: "layer name",
|
|
71
|
+
type: "layer",
|
|
72
|
+
visible: 1,
|
|
73
|
+
data: [0, 1, 1, 10, 10, 10, 1, 1, 0, 0, 0, 0, …],
|
|
74
|
+
// When the translateFlips parameter is enabled
|
|
75
|
+
flips: [
|
|
76
|
+
{H: false, V: false, D: false},
|
|
77
|
+
{H: true, V: false, D: true},
|
|
78
|
+
{H: false, V: false, D: false},
|
|
79
|
+
{…}
|
|
80
|
+
],
|
|
81
|
+
width: 512,
|
|
82
|
+
height: 128,
|
|
83
|
+
opacity: 0.77,
|
|
84
|
+
properties: {
|
|
85
|
+
property1: 'value',
|
|
86
|
+
property2: false
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
id: 2,
|
|
90
|
+
name: "objects",
|
|
91
|
+
type: "objectgroup",
|
|
92
|
+
visible: 1,
|
|
93
|
+
objects: [{…}, {…}, {…}],
|
|
94
|
+
properties: {
|
|
95
|
+
property1: 'value',
|
|
96
|
+
property2: false
|
|
97
|
+
}
|
|
98
|
+
}, {
|
|
99
|
+
…
|
|
100
|
+
}],
|
|
101
|
+
tilesets: [{
|
|
102
|
+
columns: 32,
|
|
103
|
+
firstgid: 1,
|
|
104
|
+
image: {source: "tiles.png", width: 512, height: 512},
|
|
105
|
+
name: "tiles",
|
|
106
|
+
tilecount: 1024,
|
|
107
|
+
tilewidth: 16,
|
|
108
|
+
tileheight: 16,
|
|
109
|
+
tiles: [{…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}, {…}]
|
|
110
|
+
}, {
|
|
111
|
+
…
|
|
112
|
+
}]
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## <a name="license">⚖️ License</a>
|
|
117
|
+
|
|
118
|
+
This project is licensed under the [Apache-2.0 license](https://github.com/Esposter/Esposter/blob/main/LICENSE).
|
|
119
|
+
|
|
120
|
+
[badge-license]: https://img.shields.io/github/license/Esposter/Esposter.svg?color=blue
|
|
121
|
+
[url-license]: https://github.com/Esposter/Esposter/blob/main/LICENSE
|
|
122
|
+
[badge-npm-version]: https://img.shields.io/npm/v/parse-tmx/latest?color=brightgreen
|
|
123
|
+
[url-npm]: https://www.npmjs.com/package/parse-tmx/v/latest
|
|
124
|
+
[badge-npm-unpacked-size]: https://img.shields.io/npm/unpacked-size/parse-tmx/latest?label=npm
|
|
125
|
+
[badge-npm-downloads]: https://img.shields.io/npm/dm/parse-tmx.svg
|