melonjs 20.12.0 → 20.14.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/README.md +66 -22
- package/build/application/application.d.ts +6 -1
- package/build/application/application.d.ts.map +1 -1
- package/build/application/header.d.ts.map +1 -1
- package/build/application/resize.d.ts.map +1 -1
- package/build/application/settings.d.ts +13 -8
- package/build/application/settings.d.ts.map +1 -1
- package/build/audio/audio.d.ts +8 -4
- package/build/audio/audio.d.ts.map +1 -1
- package/build/audio/backend/engine.d.ts.map +1 -1
- package/build/audio/playback.d.ts +2 -2
- package/build/audio/playback.d.ts.map +1 -1
- package/build/audio/spatial.d.ts.map +1 -1
- package/build/audio/types.d.ts +15 -5
- package/build/audio/types.d.ts.map +1 -1
- package/build/camera/camera2d.d.ts +12 -9
- package/build/camera/camera2d.d.ts.map +1 -1
- package/build/camera/camera3d.d.ts +11 -8
- package/build/camera/camera3d.d.ts.map +1 -1
- package/build/camera/effects/fade_effect.d.ts.map +1 -1
- package/build/geometries/ellipse.d.ts +3 -0
- package/build/geometries/ellipse.d.ts.map +1 -1
- package/build/geometries/line.d.ts.map +1 -1
- package/build/geometries/path2d.d.ts +9 -8
- package/build/geometries/path2d.d.ts.map +1 -1
- package/build/geometries/polygon.d.ts +2 -1
- package/build/geometries/polygon.d.ts.map +1 -1
- package/build/index.d.ts +14 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +50215 -45051
- package/build/index.js.map +4 -4
- package/build/input/gamepad.d.ts.map +1 -1
- package/build/input/keyboard.d.ts.map +1 -1
- package/build/input/pointerevent.d.ts.map +1 -1
- package/build/level/gltf/GLTFModel.d.ts.map +1 -1
- package/build/level/level.d.ts.map +1 -1
- package/build/level/tiled/TMXLayer.d.ts +50 -15
- package/build/level/tiled/TMXLayer.d.ts.map +1 -1
- package/build/level/tiled/TMXTileMap.d.ts +14 -4
- package/build/level/tiled/TMXTileMap.d.ts.map +1 -1
- package/build/level/tiled/TMXTileset.d.ts.map +1 -1
- package/build/level/tiled/TMXUtils.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXHexagonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXIsometricRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts +1 -0
- package/build/level/tiled/renderer/TMXObliqueRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXOrthogonalRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXRenderer.d.ts +7 -3
- package/build/level/tiled/renderer/TMXRenderer.d.ts.map +1 -1
- package/build/level/tiled/renderer/TMXStaggeredRenderer.d.ts.map +1 -1
- package/build/lighting/light3d.d.ts +55 -0
- package/build/lighting/light3d.d.ts.map +1 -1
- package/build/loader/cache.d.ts +146 -97
- package/build/loader/cache.d.ts.map +1 -1
- package/build/loader/internal-types.d.ts +69 -0
- package/build/loader/internal-types.d.ts.map +1 -0
- package/build/loader/loader.d.ts +589 -253
- package/build/loader/loader.d.ts.map +1 -1
- package/build/loader/parsers/audio.d.ts.map +1 -1
- package/build/loader/parsers/fontface.d.ts.map +1 -1
- package/build/loader/parsers/gltf.d.ts.map +1 -1
- package/build/loader/parsers/tmx.d.ts.map +1 -1
- package/build/math/color.d.ts +4 -0
- package/build/math/color.d.ts.map +1 -1
- package/build/math/math.d.ts +6 -1
- package/build/math/math.d.ts.map +1 -1
- package/build/math/noise.d.ts +16 -16
- package/build/math/noise.d.ts.map +1 -1
- package/build/math/observableVector2d.d.ts +6 -6
- package/build/math/observableVector2d.d.ts.map +1 -1
- package/build/math/observableVector3d.d.ts +8 -8
- package/build/math/observableVector3d.d.ts.map +1 -1
- package/build/particles/emitter.d.ts +15 -3
- package/build/particles/emitter.d.ts.map +1 -1
- package/build/particles/particle.d.ts +6 -0
- package/build/particles/particle.d.ts.map +1 -1
- package/build/particles/settings.d.ts +22 -5
- package/build/particles/settings.d.ts.map +1 -1
- package/build/physics/adapter.d.ts +64 -25
- package/build/physics/adapter.d.ts.map +1 -1
- package/build/physics/builtin/body.d.ts +23 -4
- package/build/physics/builtin/body.d.ts.map +1 -1
- package/build/physics/builtin/builtin-adapter.d.ts +25 -3
- package/build/physics/builtin/builtin-adapter.d.ts.map +1 -1
- package/build/physics/builtin/detector.d.ts.map +1 -1
- package/build/physics/builtin/raycast.d.ts.map +1 -1
- package/build/physics/world.d.ts +40 -10
- package/build/physics/world.d.ts.map +1 -1
- package/build/renderable/container.d.ts +41 -6
- package/build/renderable/container.d.ts.map +1 -1
- package/build/renderable/draggable.d.ts.map +1 -1
- package/build/renderable/frameAnimation.d.ts.map +1 -1
- package/build/renderable/instanced_mesh.d.ts +16 -14
- package/build/renderable/instanced_mesh.d.ts.map +1 -1
- package/build/renderable/mesh.d.ts +62 -5
- package/build/renderable/mesh.d.ts.map +1 -1
- package/build/renderable/renderable.d.ts.map +1 -1
- package/build/renderable/sprite.d.ts +4 -2
- package/build/renderable/sprite.d.ts.map +1 -1
- package/build/renderable/text/bitmaptext.d.ts +12 -3
- package/build/renderable/text/bitmaptext.d.ts.map +1 -1
- package/build/renderable/text/text.d.ts +147 -4
- package/build/renderable/text/text.d.ts.map +1 -1
- package/build/renderable/text/textmetrics.d.ts +10 -2
- package/build/renderable/text/textmetrics.d.ts.map +1 -1
- package/build/renderable/text/textstyle.d.ts.map +1 -1
- package/build/renderable/trigger.d.ts +5 -0
- package/build/renderable/trigger.d.ts.map +1 -1
- package/build/renderable/ui/panelpaint.d.ts +5 -1
- package/build/renderable/ui/panelpaint.d.ts.map +1 -1
- package/build/renderable/ui/progressbar.d.ts +267 -95
- package/build/renderable/ui/progressbar.d.ts.map +1 -1
- package/build/renderable/ui/uibaseelement.d.ts +443 -50
- package/build/renderable/ui/uibaseelement.d.ts.map +1 -1
- package/build/renderable/ui/uicheckbox.d.ts +383 -0
- package/build/renderable/ui/uicheckbox.d.ts.map +1 -0
- package/build/renderable/ui/uifocus.d.ts +6 -0
- package/build/renderable/ui/uifocus.d.ts.map +1 -0
- package/build/renderable/ui/uilabel.d.ts +31 -0
- package/build/renderable/ui/uilabel.d.ts.map +1 -0
- package/build/renderable/ui/uipanel.d.ts +589 -116
- package/build/renderable/ui/uipanel.d.ts.map +1 -1
- package/build/renderable/ui/uiskin.d.ts +25 -0
- package/build/renderable/ui/uiskin.d.ts.map +1 -0
- package/build/renderable/ui/uislider.d.ts +518 -0
- package/build/renderable/ui/uislider.d.ts.map +1 -0
- package/build/renderable/ui/uispriteelement.d.ts +161 -85
- package/build/renderable/ui/uispriteelement.d.ts.map +1 -1
- package/build/renderable/ui/uitextbutton.d.ts +369 -63
- package/build/renderable/ui/uitextbutton.d.ts.map +1 -1
- package/build/state/stage.d.ts.map +1 -1
- package/build/system/device.d.ts +11 -2
- package/build/system/device.d.ts.map +1 -1
- package/build/system/fullscreen.d.ts.map +1 -1
- package/build/system/pool.d.ts.map +1 -1
- package/build/system/save.d.ts +2 -1
- package/build/system/save.d.ts.map +1 -1
- package/build/tweens/tween.d.ts +5 -2
- package/build/tweens/tween.d.ts.map +1 -1
- package/build/utils/fetchdata.d.ts.map +1 -1
- package/build/utils/utils.d.ts.map +1 -1
- package/build/video/canvas/canvas_renderer.d.ts +16 -19
- package/build/video/canvas/canvas_renderer.d.ts.map +1 -1
- package/build/video/canvas_factory.d.ts.map +1 -1
- package/build/video/effects/shadereffect.d.ts +127 -0
- package/build/video/effects/shadereffect.d.ts.map +1 -1
- package/build/video/renderer.d.ts +20 -4
- package/build/video/renderer.d.ts.map +1 -1
- package/build/video/renderstate.d.ts +26 -3
- package/build/video/renderstate.d.ts.map +1 -1
- package/build/video/utils/tessellation.d.ts +11 -0
- package/build/video/utils/tessellation.d.ts.map +1 -1
- package/build/video/webgl/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgl/webgl_renderer.d.ts +3 -6
- package/build/video/webgl/webgl_renderer.d.ts.map +1 -1
- package/build/video/webgpu/batchers/lit_mesh_batcher.d.ts.map +1 -1
- package/build/video/webgpu/batchers/primitive_batcher.d.ts.map +1 -1
- package/build/video/webgpu/webgpu_renderer.d.ts +3 -6
- package/build/video/webgpu/webgpu_renderer.d.ts.map +1 -1
- package/package.json +1 -1
- package/skills/melonjs/SKILL.md +41 -17
- package/skills/melonjs-20-migration/SKILL.md +50 -7
- package/skills/melonjs-3d/SKILL.md +138 -38
- package/skills/melonjs-3d-assets/SKILL.md +83 -33
- package/skills/melonjs-audio/SKILL.md +62 -19
- package/skills/melonjs-camera-and-drawing/SKILL.md +135 -8
- package/skills/melonjs-deployment/SKILL.md +92 -14
- package/skills/melonjs-display-and-scaling/SKILL.md +8 -3
- package/skills/melonjs-effects-and-shaders/SKILL.md +47 -15
- package/skills/melonjs-events/SKILL.md +6 -3
- package/skills/melonjs-getting-started/SKILL.md +6 -2
- package/skills/melonjs-input/SKILL.md +102 -16
- package/skills/melonjs-lighting/SKILL.md +13 -1
- package/skills/melonjs-loading-assets/SKILL.md +255 -39
- package/skills/melonjs-math/SKILL.md +26 -8
- package/skills/melonjs-particles-and-trails/SKILL.md +77 -9
- package/skills/melonjs-performance/SKILL.md +18 -8
- package/skills/melonjs-physics/SKILL.md +435 -128
- package/skills/melonjs-plugins/SKILL.md +50 -11
- package/skills/melonjs-renderables/SKILL.md +31 -7
- package/skills/melonjs-renderer-backends/SKILL.md +38 -17
- package/skills/melonjs-scenes-and-state/SKILL.md +45 -5
- package/skills/melonjs-sprites-and-animation/SKILL.md +37 -2
- package/skills/melonjs-tilemaps/SKILL.md +149 -17
- package/skills/melonjs-ui-and-text/SKILL.md +674 -42
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: melonjs-tilemaps
|
|
3
|
-
description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers. Covers registerTiledObjectClass and the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, level.load, level.load async, await level.load, tileset, ImageLayer, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax, registerTiledObjectClass, registerTiledObjectFactory, TMXObject, resolvedProperty, resolvedProperties, tile class, tile properties."
|
|
3
|
+
description: "Use this skill for Tiled maps in melonJS — loading TMX/TSX levels, spawning entities from Tiled objects, collision shapes authored in Tiled, isometric and hexagonal maps, and image layers, and reading or changing tiles while the game runs. Covers registerTiledObjectClass and the pool.register name contract, camera bounds, compressed maps needing the inflate plugin, and the level director API. Triggers on: Tiled, TMX, TSX, tilemap, setTile, clearTile, cellAt, getTile, getTileById, change a tile, tile at run time, game board, grid, tile properties at run time, getTileProperties, map properties, level.load, level.load async, await level.load, tileset, ImageLayer, infinite map, render order, isometric, hexagonal, staggered, pool.register, Collectable, Trigger, object layer, collision layer, parallax, registerTiledObjectClass, registerTiledObjectFactory, TMXObject, resolvedProperty, resolvedProperties, tile class, tile properties."
|
|
4
4
|
license: MIT
|
|
5
5
|
---
|
|
6
6
|
|
|
@@ -25,12 +25,29 @@ await loader.preload([
|
|
|
25
25
|
level.load("map1"); // inside Stage.onResetEvent
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
+
**A game with several maps** keeps each map and the images only it uses in a
|
|
29
|
+
bundle of its own, beside a `common` bundle for the shared tileset, the player
|
|
30
|
+
and the sounds: an assets file exporting `{ common: [...], map1: [...],
|
|
31
|
+
map2: [...] }`, passed as it is to `loader.preload()`. A map's level can then be
|
|
32
|
+
freed with `loader.unload("map1")` and brought back with
|
|
33
|
+
`await loader.load("map1")` before `level.load("map1")`; a game whose maps
|
|
34
|
+
loop back simply keeps them all loaded. `melonjs-loading-assets` covers the
|
|
35
|
+
pattern.
|
|
36
|
+
|
|
28
37
|
Asset `type` is `"tmx"` for maps and `"tsx"` for external tilesets — those are
|
|
29
38
|
the only two type strings the loader knows. The *file* can be `.tmx` / `.tsx`
|
|
30
39
|
(XML), or `.json` / `.tmj` / `.tsj`; the parser branches on the extension, not
|
|
31
40
|
on the type. `type: "tmj"` throws `unknown or invalid resource type`. You can
|
|
32
|
-
also skip `src` and pass the map inline via `data
|
|
33
|
-
|
|
41
|
+
also skip `src` and pass the map inline via `data`, as the parsed JSON object
|
|
42
|
+
of a Tiled JSON export (not an XML string).
|
|
43
|
+
|
|
44
|
+
**Prefer JSON where there is no DOM.** XML maps and tilesets are parsed with
|
|
45
|
+
`DOMParser`, which only a page has: in a Web Worker, or on nx.js (the Nintendo
|
|
46
|
+
Switch, see `melonjs-deployment`), loading one fails, and `preload()` rejects
|
|
47
|
+
with "Failed loading resource …" whose `cause` (also logged to the console)
|
|
48
|
+
says to export it as JSON. Export the map *and* its external tilesets as
|
|
49
|
+
`.tmj` / `.tsj` (Tiled: File → Export As, or set JSON as the format in the
|
|
50
|
+
project).
|
|
34
51
|
|
|
35
52
|
`level.load(levelId, options)` accepts `container` (default `game.world`),
|
|
36
53
|
`onLoaded` (default `game.onLevelLoaded`), `flatten` (default `game.mergeGroup`),
|
|
@@ -178,16 +195,113 @@ authored against melonJS 1.x finds them where it looks.
|
|
|
178
195
|
|
|
179
196
|
A `Trigger` forwards a **fixed list** of settings to `level.load()` — not
|
|
180
197
|
whatever you pass it. Today that list is `container`, `onLoaded`, `flatten`,
|
|
181
|
-
`setViewportBounds` and the glTF scene options
|
|
182
|
-
`lights`, `lightIntensityScale
|
|
183
|
-
|
|
198
|
+
`setViewportBounds` and the glTF scene options: `scale`, `rightHanded`,
|
|
199
|
+
`lights`, `lightIntensityScale` and the ground-shadow settings
|
|
200
|
+
(`castGroundShadow`, `shadowGroundY`, `shadowOpacity`, `shadowScale`,
|
|
201
|
+
`shadowOffset`, `shadowStretch`, `shadowDirectionX`, `shadowDirectionZ`,
|
|
202
|
+
`shadowGroundNormal`, `shadowLight`, but not `shadowGroundPoint`); see the 3D
|
|
203
|
+
assets skill. Anything outside it is **dropped silently**, which is worth
|
|
184
204
|
knowing before you spend an afternoon on a map that loads at the wrong scale.
|
|
185
205
|
`async` is excluded deliberately — the trigger needs to sequence its own
|
|
186
206
|
transition.
|
|
187
207
|
|
|
208
|
+
## Reading and changing tiles at run time
|
|
209
|
+
|
|
210
|
+
A tile layer is a live grid, not just a picture: read it as the game board,
|
|
211
|
+
and change cells while the game runs — a door opening, a floor panel lighting
|
|
212
|
+
up, a wall blown away. A loaded tile layer is a `TMXLayer` in the world, under
|
|
213
|
+
the name it has in Tiled:
|
|
214
|
+
|
|
215
|
+
```js
|
|
216
|
+
await level.load("map1", { container: this.app.world, async: true });
|
|
217
|
+
const board = this.app.world.getChildByName("ground")[0]; // a TMXLayer
|
|
218
|
+
board.cols; board.rows; // the grid, in cells
|
|
219
|
+
board.tilewidth; board.tileheight; // a cell, in pixels
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
Two coordinate systems, and the methods do not share one:
|
|
223
|
+
|
|
224
|
+
| method | takes | returns |
|
|
225
|
+
|---|---|---|
|
|
226
|
+
| `cellAt(col, row)` | column and row | the `Tile` there, or `null` for an empty cell or outside the grid |
|
|
227
|
+
| `getTile(x, y)` | **world pixels** | the same `Tile` object `cellAt` gives, or `null` |
|
|
228
|
+
| `setTile(tile, col, row)` | column and row | puts `tile` there, and returns it |
|
|
229
|
+
| `clearTile(col, row)` | column and row | empties the cell: `cellAt` then returns `null` |
|
|
230
|
+
| `getTileById(gid, col, row)` | a global tile id, column and row | a new `Tile`, to pass to `setTile` |
|
|
231
|
+
|
|
232
|
+
Columns and rows are the map's tile coordinates, the ones Tiled shows. On an
|
|
233
|
+
**infinite** map a layer can hold tiles left of or above the map's origin:
|
|
234
|
+
there `board.startx` / `board.starty` are negative, its cells run from
|
|
235
|
+
`startx` to `startx + cols - 1` (and `starty` to `starty + rows - 1`), and
|
|
236
|
+
`cellAt(-3, -2)` is the tile Tiled shows at (-3, -2), drawn where Tiled draws
|
|
237
|
+
it. On a finite map both are 0:
|
|
238
|
+
|
|
239
|
+
```js
|
|
240
|
+
for (let row = board.starty; row < board.starty + board.rows; row++) {
|
|
241
|
+
for (let col = board.startx; col < board.startx + board.cols; col++) {
|
|
242
|
+
const tile = board.cellAt(col, row); // every cell, infinite maps included
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
An infinite map's `getBounds()` (and its `width` / `height`) covers the map's
|
|
248
|
+
own area and every painted tile, so a level loaded with `setViewportBounds`
|
|
249
|
+
lets the camera reach tiles painted past the map's size, or left of or above
|
|
250
|
+
its origin. Empty chunk cells past the last painted tile are not part of it.
|
|
251
|
+
Size a camera you set up yourself from `map.getBounds()`, not from
|
|
252
|
+
`cols * tilewidth`, which is only right for an orthogonal map:
|
|
253
|
+
|
|
254
|
+
```js
|
|
255
|
+
const b = level.getCurrentLevel().getBounds();
|
|
256
|
+
app.viewport.setBounds(b.left, b.top, b.width, b.height);
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
A `Tile` carries `tileId` (its **global** id), `col`, `row` and `tileset`.
|
|
260
|
+
Tiled shows a tile's *local* id in the tileset editor; the global id is
|
|
261
|
+
`tileset.firstgid + localId`, and only the global one works with `setTile`.
|
|
262
|
+
The tile's custom properties and class, set in Tiled's tileset editor, come
|
|
263
|
+
from its tileset by global id:
|
|
264
|
+
|
|
265
|
+
```js
|
|
266
|
+
const tile = board.cellAt(col, row);
|
|
267
|
+
const props = tile && tile.tileset.getTileProperties(tile.tileId); // { kind: "floor" } or undefined
|
|
268
|
+
const cls = tile && tile.tileset.getTileClass(tile.tileId);
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
To swap a cell for another tile of the tileset, build the tile and set it. Look
|
|
272
|
+
global ids up by property once, rather than hard-coding them, so a designer
|
|
273
|
+
can rearrange the tileset:
|
|
274
|
+
|
|
275
|
+
```js
|
|
276
|
+
const tileset = board.tilesets.getTilesetByIndex(0); // the layer's first tileset
|
|
277
|
+
const gidByKind = new Map();
|
|
278
|
+
for (let gid = tileset.firstgid; gid <= tileset.lastgid; gid++) {
|
|
279
|
+
const kind = tileset.getTileProperties(gid)?.kind;
|
|
280
|
+
if (kind !== undefined) gidByKind.set(kind, gid);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
// light a floor panel up
|
|
284
|
+
board.setTile(board.getTileById(gidByKind.get("floor-lit"), col, row), col, row);
|
|
285
|
+
// knock a wall down
|
|
286
|
+
board.clearTile(col, row);
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
The layer redraws the changed cell by itself. What it does **not** change is
|
|
290
|
+
collision: solid ground comes from collision object layers (below), so a tile
|
|
291
|
+
set or cleared changes what is drawn and what `cellAt` returns, not what a body
|
|
292
|
+
runs into. Keep a layer you edit often off `preRender` (see the symptom table).
|
|
293
|
+
|
|
294
|
+
The map's own custom properties (Map → Map Properties in Tiled) are set on the
|
|
295
|
+
map object, which `level.getCurrentLevel()` returns once it is loaded: a
|
|
296
|
+
`theme` string property is `level.getCurrentLevel().theme`. They are set
|
|
297
|
+
**over** the map's own fields, so a property named like one replaces it: a
|
|
298
|
+
custom `name` property becomes the level's `name`. Give level settings names of
|
|
299
|
+
their own (`title`, not `name`).
|
|
300
|
+
|
|
188
301
|
## Camera bounds
|
|
189
302
|
|
|
190
|
-
`level.load` sets the viewport bounds to the map
|
|
303
|
+
`level.load` sets the viewport bounds to the map's bounds for you (on an
|
|
304
|
+
infinite map, every painted tile, see above) —
|
|
191
305
|
`setViewportBounds` defaults to `true`, and the handler is re-run on every
|
|
192
306
|
viewport resize, centring the map when it is smaller than the screen. You only
|
|
193
307
|
need to do it by hand when you opted out:
|
|
@@ -331,23 +445,27 @@ per-pixel GID lookup in the fragment shader. It requires **all** of:
|
|
|
331
445
|
- `world.gpuTilemap !== false` (the `gpuTilemap` application setting, default `true`),
|
|
332
446
|
- an **orthogonal** layer — isometric, hexagonal, staggered and oblique always
|
|
333
447
|
fall back,
|
|
334
|
-
- no collection-of-image tileset, no non-zero `tileoffset`,
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
448
|
+
- no collection-of-image tileset, no non-zero `tileoffset`, a tileset tile
|
|
449
|
+
render size of "Tile size" (`tilerendersize`, not "Map grid size"), and tile
|
|
450
|
+
overflow within the shader's 4-cell limit.
|
|
451
|
+
|
|
452
|
+
When a layer falls back, melonJS `console.warn`s the reason each time the
|
|
453
|
+
layer is activated (once per page when the renderer has no GPU tile support at
|
|
454
|
+
all), and says nothing while `gpuTilemap` is off. Practical consequences:
|
|
455
|
+
fewer tilesets means fewer batches (one packed tileset beats several small
|
|
456
|
+
ones), and on the Canvas fallback large maps get noticeably slower.
|
|
457
|
+
`world.preRender` (or a `preRender` layer property in Tiled) opts an unanimated
|
|
458
|
+
layer into the offscreen-bake path instead.
|
|
342
459
|
|
|
343
460
|
## Symptom → cause
|
|
344
461
|
|
|
345
462
|
| symptom | cause |
|
|
346
463
|
|---|---|
|
|
464
|
+
| objects a screen added just before `level.load` draw in the order they were added (a background over everything) | before 20.13 the reset inside `level.load` dropped the sort still pending for the persistent children it kept; update, or call `sort()` on their container once the level is loaded |
|
|
347
465
|
| a Tiled object becomes a plain shape with no behaviour | its class/name does not match any registered factory, or it was registered after `level.load` |
|
|
348
466
|
| the world is still empty right after `level.load` | the load is deferred to a timer while the loop runs — `await level.load(id, { async: true })`, or use `onLoaded` / `LEVEL_LOADED` |
|
|
349
467
|
| `await level.load(id)` returned `true` rather than a promise | without `async: true` the call returns a boolean; `await true` resolves immediately and the load has not run yet — pass the flag when you mean to await |
|
|
350
|
-
| `level <id> not found` | the map was never preloaded, or the asset `name` differs from the id passed to `load` |
|
|
468
|
+
| `level <id> not found` | the map was never preloaded, its bundle was unloaded (`await loader.load(bundleId)` first), or the asset `name` differs from the id passed to `load` |
|
|
351
469
|
| `unknown or invalid resource type` | asset `type` set to `"tmj"` / `"tsj"` — use `"tmx"` / `"tsx"` with the `.tmj` / `.tsj` file |
|
|
352
470
|
| camera will not scroll | `setViewportBounds: false`, or the map was added with `addTo()` (which defaults to `false`) |
|
|
353
471
|
| `No inflate function set` at parse time | compressed layers without the tiled-inflate plugin |
|
|
@@ -361,7 +479,21 @@ unanimated layer into the offscreen-bake path instead.
|
|
|
361
479
|
| a property set on a tile is undefined on the object's `settings` | tile properties are not copied onto `settings`: read them with `settings.resolvedProperty(name)` |
|
|
362
480
|
| objects placed from a classed tile come out as plain sprites | that class is not registered, it is a built-in name, or the object has a class or a registered name of its own, which come first |
|
|
363
481
|
| missing tiles or a blank map | the `.tsx` or tileset image was not preloaded |
|
|
364
|
-
| a
|
|
482
|
+
| a map fails to load with "needs DOMParser" (in the error's `cause` and the console) | an XML `.tmx` / `.tsx` loaded where there is no DOM (a Web Worker, nx.js): export the map and its tilesets as JSON (`.tmj` / `.tsj`) |
|
|
483
|
+
| a tileset's transparent color (`trans`) still shows (the console says it could not be applied) | the image cannot be read back: an image the game made itself from another origin without CORS (an `<img>` with no `crossOrigin`) cannot be, so load it with the loader, which only loads an image another origin's server allows (its CORS headers) and can always read back; and a compressed texture cannot be changed: export it with an alpha channel instead |
|
|
484
|
+
| `cellAt` returns `null` (or the wrong tile) for a cell that has one | it was given pixels: `cellAt`, `setTile` and `clearTile` take column and row, only `getTile` takes world pixels |
|
|
485
|
+
| `setTile` shows the wrong tile, or nothing | it was given Tiled's local tile id: use the global id, `tileset.firstgid + localId`, through `getTileById` |
|
|
486
|
+
| on an infinite map the camera stops before tiles painted past the map's size, or left of or above its origin | an older melonJS held the camera to the map's width and height from (0, 0): update; and size a camera you set up yourself from `map.getBounds()` |
|
|
487
|
+
| oversized tiles overlap in the wrong order (the map's render order is not "right-down") | an older melonJS drew every layer "right-down", whatever the map's render order: update |
|
|
488
|
+
| an infinite map's tiles sit in the wrong row, or tiles left of or above the origin are missing | an older melonJS ignored where the chunks start (update); and loop from `layer.startx` / `layer.starty`, not 0, to reach cells left of or above the origin |
|
|
489
|
+
| on a staggered map `getTile` gives the neighbouring tile on every row but the first, or a scrolled view draws nothing | a bug of older melonJS versions in the staggered renderer: update |
|
|
490
|
+
| on an isometric (or staggered, oblique) map `getTile` gives an edge tile for a point just outside the tiles | an older melonJS rounded a fractional column or row toward 0: update |
|
|
491
|
+
| on an isometric map a tile drawn by hand with the map renderer's `drawTile()` lands away from where the layer draws that cell | before 20.14 the isometric `drawTile()` placed it differently from the layer: update |
|
|
492
|
+
| a repeating `ImageLayer` slides off the screen once the camera has moved far enough | before 20.12 its repeat did not follow the camera: update |
|
|
493
|
+
| tiles of a second tileset draw from the first tileset's image (that first one has a `margin`) | an older melonJS let its gid range overrun into the next tileset (update): the range is the `tilecount` Tiled saved |
|
|
494
|
+
| a layer is `undefined` from `getChildByName(name)[0]` | the level is not in the world yet (await `level.load(id, { async: true })`), or the name differs from the layer's in Tiled |
|
|
495
|
+
| a tile set or cleared at run time does not block or free movement | tile layers carry no collision: collision comes from collision object layers |
|
|
496
|
+
| the level's `name` is not its id after loading | a map custom property named `name` replaced it: map properties are set over the map's own fields |
|
|
365
497
|
| changing tiles at runtime is slow on a pre-rendered layer | outside an orthogonal map whose tiles fit their cells, a changed tile re-bakes the whole layer before it next draws: keep layers you edit often off `preRender` |
|
|
366
498
|
| thin lines between tiles on the Canvas renderer, with smoothing on | filtering blends in the next tile of the tileset or its spacing, which a canvas cannot prevent: set `antiAlias: false`, or `preRender` the layer. WebGL and WebGPU keep each tile to itself |
|
|
367
499
|
| tilemap slow on some machines | layer fell back off the shader path — check the console warning for the reason |
|