pixi-tiledmap 1.10.1 → 2.1.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.md +21 -21
- package/README.md +131 -232
- package/dist/index.cjs +1319 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +488 -0
- package/dist/index.d.cts.map +1 -0
- package/dist/index.d.mts +488 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +1298 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +70 -59
- package/.babelrc +0 -10
- package/.git/hooks/README.sample +0 -5
- package/dist/pixi-tiledmap.d.ts +0 -163
- package/dist/pixi-tiledmap.js +0 -18180
- package/dist/pixi-tiledmap.js.map +0 -1
- package/dist/pixi-tiledmap.min.js +0 -17
- package/dist/pixi-tiledmap.min.js.map +0 -1
- package/docs/assets/css/main.css +0 -865
- package/docs/assets/css/main.css.map +0 -7
- package/docs/assets/images/icons.png +0 -0
- package/docs/assets/images/icons@2x.png +0 -0
- package/docs/assets/images/widgets.png +0 -0
- package/docs/assets/images/widgets@2x.png +0 -0
- package/docs/assets/js/main.js +0 -5
- package/docs/assets/js/search.js +0 -3
- package/docs/classes/_imagelayer_.imagelayer.html +0 -2696
- package/docs/classes/_tile_.tile.html +0 -3818
- package/docs/classes/_tiledmap_.tiledmap.html +0 -2834
- package/docs/classes/_tilelayer_.tilelayer.html +0 -2792
- package/docs/classes/_tileset_.tileset.html +0 -412
- package/docs/globals.html +0 -192
- package/docs/index.html +0 -372
- package/docs/interfaces/_index_.__global.pixi.extras.itiledmap.html +0 -209
- package/docs/interfaces/_types_interfaces_.ianimation.html +0 -250
- package/docs/interfaces/_types_interfaces_.ilayerdata.html +0 -376
- package/docs/interfaces/_types_interfaces_.itiledata.html +0 -334
- package/docs/interfaces/_types_interfaces_.itilesetdata.html +0 -421
- package/docs/interfaces/_types_interfaces_.itmxdata.html +0 -362
- package/docs/modules/_imagelayer_.html +0 -191
- package/docs/modules/_index_.__global.html +0 -167
- package/docs/modules/_index_.__global.pixi.extras.html +0 -176
- package/docs/modules/_index_.__global.pixi.html +0 -170
- package/docs/modules/_index_.html +0 -188
- package/docs/modules/_tile_.html +0 -191
- package/docs/modules/_tiledmap_.html +0 -191
- package/docs/modules/_tiledmaploader_.html +0 -217
- package/docs/modules/_tilelayer_.html +0 -191
- package/docs/modules/_tileset_.html +0 -191
- package/docs/modules/_types_interfaces_.html +0 -207
- package/examples/browser/assets/01_basement.tmx +0 -11
- package/examples/browser/assets/meta.png +0 -0
- package/examples/browser/index.html +0 -32
- package/examples/webpack/.eslintrc.json +0 -37
- package/examples/webpack/package.json +0 -26
- package/examples/webpack/src/assets/01_basement.tmx +0 -11
- package/examples/webpack/src/assets/meta.png +0 -0
- package/examples/webpack/src/index.html +0 -9
- package/examples/webpack/src/index.js +0 -18
- package/examples/webpack/webpack.config.js +0 -42
- package/examples/webpack/yarn.lock +0 -4733
- package/src/ImageLayer.ts +0 -14
- package/src/Tile.ts +0 -82
- package/src/TileLayer.ts +0 -77
- package/src/TileSet.ts +0 -41
- package/src/TiledMap.ts +0 -66
- package/src/index.ts +0 -17
- package/src/tiledMapLoader.ts +0 -36
- package/src/types/interfaces.ts +0 -78
- package/src/types/tmx-parser.d.ts +0 -3
- package/tsconfig.json +0 -21
- package/tslint.json +0 -9
- package/webpack.config.js +0 -66
package/LICENSE.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2015 Hagen Sommerkorn
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2015 Hagen Sommerkorn
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,232 +1,131 @@
|
|
|
1
|
-
# pixi-tiledmap [![NPM version][npm-image]][npm-url]
|
|
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
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
children: (2) [Graphics, TileLayer]
|
|
133
|
-
filterArea: null
|
|
134
|
-
layers: Array(1)
|
|
135
|
-
0: TileLayer
|
|
136
|
-
diagonalFlips: (187) [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, …]
|
|
137
|
-
horizontalFlips: (187) [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, …]
|
|
138
|
-
map: Map {version: "1.0", orientation: "orthogonal", width: 17, height: 11, tileWidth: 26, …}
|
|
139
|
-
name: "meta"
|
|
140
|
-
opacity: 0.2
|
|
141
|
-
properties: {}
|
|
142
|
-
tiles: (283) [Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, Tile, 49: Tile, 50: Tile, 51: Tile, 52: Tile, 66: Tile, 67: Tile, 68: Tile, 69: Tile, 83: Tile, 84: Tile, 85: Tile, 86: Tile, 100: Tile, 101: Tile, 102: Tile, 103: Tile, 117: Tile, 118: Tile, 119: Tile, 120: Tile, 134: Tile, 135: Tile, 136: Tile, 137: Tile, 151: Tile, 152: Tile, 153: Tile, 154: Tile, 155: Tile, 156: Tile, 157: Tile, 158: Tile, 159: Tile, 160: Tile, 161: Tile, 162: Tile, 163: Tile, 164: Tile, 165: Tile, 166: Tile, 167: Tile, 168: Tile, 169: Tile, 170: Tile, 171: Tile, 172: Tile, 173: Tile, 174: Tile, 175: Tile, 176: Tile, 177: Tile, 178: Tile, 179: Tile, 180: Tile, 181: Tile, 182: Tile, 183: Tile, 184: Tile, 185: Tile, 186: Tile, 187: Tile, 188: Tile, 189: Tile, 190: Tile, …]
|
|
143
|
-
type: "tile"
|
|
144
|
-
verticalFlips: (187) [false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, false, …]
|
|
145
|
-
visible: true
|
|
146
|
-
__proto__: Object
|
|
147
|
-
meta: TileLayer {_events: Events, _eventsCount: 0, tempDisplayObjectParent: null, transform: TransformStatic, alpha: 0.2, …}
|
|
148
|
-
length: 1
|
|
149
|
-
__proto__: Array(0)
|
|
150
|
-
orientation: "orthogonal"
|
|
151
|
-
parent: null
|
|
152
|
-
properties: {}
|
|
153
|
-
renderable: true
|
|
154
|
-
resourceUrl: "assets/01_basement.tmx"
|
|
155
|
-
tempDisplayObjectParent: DisplayObject {_events: Events, _eventsCount: 0, tempDisplayObjectParent: null, transform: TransformStatic, alpha: 1, …}
|
|
156
|
-
tileHeight: 26
|
|
157
|
-
tileSets: Array(2)
|
|
158
|
-
0: TileSet
|
|
159
|
-
firstGid: 1
|
|
160
|
-
image: Image {format: undefined, source: "meta.png", trans: undefined, width: 52, height: 26}
|
|
161
|
-
margin: null
|
|
162
|
-
name: "meta"
|
|
163
|
-
properties: {}
|
|
164
|
-
source: undefined
|
|
165
|
-
spacing: null
|
|
166
|
-
terrainTypes: []
|
|
167
|
-
tileHeight: 26
|
|
168
|
-
tileOffset: {x: 0, y: 0}
|
|
169
|
-
tileWidth: 26
|
|
170
|
-
tiles: Array(2)
|
|
171
|
-
0: Tile
|
|
172
|
-
animations: []
|
|
173
|
-
gid: 1
|
|
174
|
-
id: 0
|
|
175
|
-
image: null
|
|
176
|
-
objectGroups: []
|
|
177
|
-
probability: null
|
|
178
|
-
properties: {}
|
|
179
|
-
terrain: []
|
|
180
|
-
__proto__: Object
|
|
181
|
-
1: Tile {id: 1, terrain: Array(0), probability: null, properties: {…}, animations: Array(0), …}
|
|
182
|
-
length: 2
|
|
183
|
-
__proto__: Array(0)
|
|
184
|
-
__proto__: Object
|
|
185
|
-
1: TileSet {firstGid: 1, baseTexture: Texture, textures: Array(2), margin: null, spacing: null, …}
|
|
186
|
-
length: 2
|
|
187
|
-
__proto__: Array(0)
|
|
188
|
-
tileWidth: 26
|
|
189
|
-
trackedPointers: (...)
|
|
190
|
-
transform: TransformStatic {worldTransform: Matrix, localTransform: Matrix, _worldID: 0, _parentID: 0, position: ObservablePoint, …}
|
|
191
|
-
version: "1.0"
|
|
192
|
-
visible: true
|
|
193
|
-
worldAlpha: 1
|
|
194
|
-
_bounds: Bounds {minX: Infinity, minY: Infinity, maxX: -Infinity, maxY: -Infinity, rect: null, …}
|
|
195
|
-
_boundsID: 5
|
|
196
|
-
_boundsRect: null
|
|
197
|
-
_destroyed: false
|
|
198
|
-
_enabledFilters: null
|
|
199
|
-
_events: Events {}
|
|
200
|
-
_eventsCount: 0
|
|
201
|
-
_filters: null
|
|
202
|
-
_height: 11
|
|
203
|
-
_lastBoundsID: 2
|
|
204
|
-
_localBoundsRect: Rectangle {x: 0, y: 0, width: 0, height: 0, type: 1}
|
|
205
|
-
_mask: null
|
|
206
|
-
_width: 17
|
|
207
|
-
cacheAsBitmap: (...)
|
|
208
|
-
filters: (...)
|
|
209
|
-
height: (...)
|
|
210
|
-
localTransform: (...)
|
|
211
|
-
mask: (...)
|
|
212
|
-
pivot: (...)
|
|
213
|
-
position: (...)
|
|
214
|
-
rotation: (...)
|
|
215
|
-
scale: (...)
|
|
216
|
-
skew: (...)
|
|
217
|
-
width: (...)
|
|
218
|
-
worldTransform: (...)
|
|
219
|
-
worldVisible: (...)
|
|
220
|
-
x: (...)
|
|
221
|
-
y: (...)
|
|
222
|
-
_tempDisplayObjectParent: (...)
|
|
223
|
-
__proto__: Container
|
|
224
|
-
}
|
|
225
|
-
```
|
|
226
|
-
|
|
227
|
-
## To do
|
|
228
|
-
|
|
229
|
-
support isometric and hexagonal orientation
|
|
230
|
-
|
|
231
|
-
[npm-url]: https://npmjs.org/package/pixi-tiledmap
|
|
232
|
-
[npm-image]: http://img.shields.io/npm/v/pixi-tiledmap.svg?style=flat
|
|
1
|
+
# pixi-tiledmap v2 [![NPM version][npm-image]][npm-url]
|
|
2
|
+
|
|
3
|
+
Load and render [Tiled Map Editor](http://www.mapeditor.org/) maps with [PixiJS v8](https://pixijs.com/).
|
|
4
|
+
|
|
5
|
+
**v2** is a ground-up rewrite targeting PixiJS v8, with its own Tiled JSON and TMX XML parser (no external deps), full layer-type support, typed API, and ESM/CJS dual output.
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **PixiJS v8** — uses the modern `Assets` / `LoadParser` extension system
|
|
10
|
+
- **Tiled JSON + TMX XML** — full spec coverage (Tiled 1.11), both `.tmj` and `.tmx` formats
|
|
11
|
+
- **All layer types** — tile, image, object, and group layers
|
|
12
|
+
- **All orientations** — orthogonal, isometric, staggered, hexagonal
|
|
13
|
+
- **Render order** — right-down, right-up, left-down, left-up
|
|
14
|
+
- **Infinite maps** — chunk-based tile layer rendering
|
|
15
|
+
- **Tile features** — animated tiles, flip/rotation flags, image-collection tilesets, tint color
|
|
16
|
+
- **Object rendering** — rectangles, ellipses, polygons, polylines, points, text, tile objects
|
|
17
|
+
- **Data encoding** — CSV and base64 (uncompressed, gzip, zlib)
|
|
18
|
+
- **External tilesets** — automatic resolution via the asset loader (`.tsj` and `.tsx`)
|
|
19
|
+
- **Tree-shakable** — ESM + CJS dual build, side-effect-free
|
|
20
|
+
- **Typed** — comprehensive TypeScript types for the full Tiled spec
|
|
21
|
+
|
|
22
|
+
## Installation
|
|
23
|
+
|
|
24
|
+
```sh
|
|
25
|
+
npm install pixi-tiledmap pixi.js
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Quick Start — Asset Loader (recommended)
|
|
29
|
+
|
|
30
|
+
Register the loader extension once, then load `.tmj` (JSON) or `.tmx` (XML) files through `Assets`:
|
|
31
|
+
|
|
32
|
+
```ts
|
|
33
|
+
import { Application, extensions, Assets } from 'pixi.js';
|
|
34
|
+
import { tiledMapLoader } from 'pixi-tiledmap';
|
|
35
|
+
|
|
36
|
+
extensions.add(tiledMapLoader);
|
|
37
|
+
|
|
38
|
+
const app = new Application();
|
|
39
|
+
await app.init({ width: 800, height: 600 });
|
|
40
|
+
document.body.appendChild(app.canvas);
|
|
41
|
+
|
|
42
|
+
const { container } = await Assets.load('assets/map.tmj');
|
|
43
|
+
app.stage.addChild(container);
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
> The loader auto-detects the format by file extension: `.tmj` → JSON, `.tmx` → XML.
|
|
47
|
+
|
|
48
|
+
## Manual Construction
|
|
49
|
+
|
|
50
|
+
If you prefer to parse and build the display tree yourself:
|
|
51
|
+
|
|
52
|
+
```ts
|
|
53
|
+
import { parseMap, TiledMap } from 'pixi-tiledmap';
|
|
54
|
+
import { Assets, Texture } from 'pixi.js';
|
|
55
|
+
import type { TiledMap as TiledMapData } from 'pixi-tiledmap';
|
|
56
|
+
|
|
57
|
+
const response = await fetch('assets/map.tmj');
|
|
58
|
+
const data: TiledMapData = await response.json();
|
|
59
|
+
|
|
60
|
+
const mapData = parseMap(data);
|
|
61
|
+
|
|
62
|
+
const tilesetTextures = new Map<string, Texture>();
|
|
63
|
+
for (const ts of mapData.tilesets) {
|
|
64
|
+
if (ts.image) {
|
|
65
|
+
tilesetTextures.set(ts.image, await Assets.load(ts.image));
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const container = new TiledMap(mapData, { tilesetTextures });
|
|
70
|
+
app.stage.addChild(container);
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
## API Reference
|
|
74
|
+
|
|
75
|
+
### Exports
|
|
76
|
+
|
|
77
|
+
| Export | Description |
|
|
78
|
+
| --------------------- | ---------------------------------------------------------------- |
|
|
79
|
+
| `tiledMapLoader` | PixiJS `LoadParser` extension — register with `extensions.add()` |
|
|
80
|
+
| `TiledMap` | `Container` subclass that renders a resolved map |
|
|
81
|
+
| `TileLayerRenderer` | `Container` for a single tile layer |
|
|
82
|
+
| `ImageLayerRenderer` | `Container` for a single image layer |
|
|
83
|
+
| `ObjectLayerRenderer` | `Container` for a single object layer |
|
|
84
|
+
| `GroupLayerRenderer` | `Container` for a group layer (recursive) |
|
|
85
|
+
| `TileSetRenderer` | Texture manager for a tileset |
|
|
86
|
+
| `parseMap(data)` | Synchronous Tiled JSON → resolved IR |
|
|
87
|
+
| `parseMapAsync(data)` | Async variant (required for gzip/zlib compressed data) |
|
|
88
|
+
| `parseTmx(xml)` | Parse TMX XML string → `TiledMap` data (same shape as JSON) |
|
|
89
|
+
| `parseTsx(xml)` | Parse TSX XML string → `TiledTileset` data |
|
|
90
|
+
| `decodeGid(raw)` | Decode a raw GID into tile ID + flip flags |
|
|
91
|
+
|
|
92
|
+
### `TiledMap` Container
|
|
93
|
+
|
|
94
|
+
```ts
|
|
95
|
+
const map = new TiledMap(resolvedMap, {
|
|
96
|
+
tilesetTextures, // Map<imagePath, Texture>
|
|
97
|
+
imageLayerTextures, // Map<imagePath, Texture>
|
|
98
|
+
tileImageTextures, // Map<imagePath, Texture> (image-collection tiles)
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
map.orientation; // 'orthogonal' | 'isometric' | 'staggered' | 'hexagonal'
|
|
102
|
+
map.mapWidth; // tile columns
|
|
103
|
+
map.mapHeight; // tile rows
|
|
104
|
+
map.tileWidth; // tile pixel width
|
|
105
|
+
map.tileHeight; // tile pixel height
|
|
106
|
+
map.getLayer('ground'); // find layer Container by name
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Migration from v1
|
|
110
|
+
|
|
111
|
+
| v1 (PixiJS v4) | v2 (PixiJS v8) |
|
|
112
|
+
| ------------------------------------- | -------------------------------------------------------- |
|
|
113
|
+
| `PIXI.loader.add('map.tmx').load(…)` | `extensions.add(tiledMapLoader); Assets.load('map.tmj')` |
|
|
114
|
+
| `new PIXI.extras.TiledMap('map.tmx')` | `const { container } = await Assets.load('map.tmj')` |
|
|
115
|
+
| Global namespace mutation | Named ESM imports |
|
|
116
|
+
| TMX XML via `tmx-parser` | Built-in JSON + XML parser (no external deps) |
|
|
117
|
+
| Tile + image layers only | All layer types |
|
|
118
|
+
|
|
119
|
+
## Development
|
|
120
|
+
|
|
121
|
+
```sh
|
|
122
|
+
npm install
|
|
123
|
+
npm run build # ESM + CJS + types via tsdown
|
|
124
|
+
npm run dev # watch mode
|
|
125
|
+
npm run check # Biome lint + format
|
|
126
|
+
npm run typecheck # tsc --noEmit
|
|
127
|
+
npm test # Vitest
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
[npm-url]: https://npmjs.org/package/pixi-tiledmap
|
|
131
|
+
[npm-image]: http://img.shields.io/npm/v/pixi-tiledmap.svg?style=flat
|