melonjs-tilemaps
Was er macht
Es erklärt, wie man im Karteneditor Tiled erstellte Level lädt und Kartenobjekte mit dem Spielcode verbindet. Es richtet sich an Spieleentwickler, die Level mit Tiled bauen.
Wann du ihn nutzt
- ✓Wenn ein Entwickler ein im Tiled-Karteneditor erstelltes Level laden will.
- ✓Wenn ein Entwickler will, dass Gegner oder Gegenstände dort erscheinen, wo sie in Tiled platziert wurden.
- ✓Wenn die Karte eines Entwicklers nicht lädt, weil ein Tileset oder Bild nicht vorgeladen wurde.
Link zum Skill
https://github.com/melonjs/melonJS/blob/master/packages/melonjs/skills/melonjs-tilemaps/SKILL.mdKopiere ihn und füge ihn in deine KI ein (Claude, ChatGPT oder Cursor) mit der Bitte, den Anweisungen zu folgen.
So nutzt du ihn
Am einfachsten: Kopiere die Nachricht und füge sie in deine KI ein. Sie liest den Skill und folgt den Anweisungen.
Fertige Nachricht zum Einfügen
Für Claude Code, Codex oder Cursor: Führe den Befehl in deinem Projektordner aus, dann wird der Skill installiert.
Lade die SKILL.md herunter und lege sie in den Skills-Ordner deines Agenten.
Beispielanfrage an deine KI
“Lade mein Tiled-Level ins Spiel und erzeuge die Münzen, die ich in der Karte platziert habe.”
5 neue Skills pro Woche. 1 Minute Lesezeit.
So funktioniert es
Die Fähigkeit weist den KI-Agenten an, die Karte, ihre externen Tilesets und Bilder vorzuladen, dann das Level zu laden und die Spielobjekt-Klassen zu registrieren, damit sie aus den Tiled-Objekten erscheinen.
Technischer Inhalt (originale SKILL.md)
Originaltext des Autors, auf Englisch, direkt von GitHub.
Tiled maps
melonJS's flagship content pipeline. Maps are authored in Tiled and loaded through the
leveldirector — you rarely touch theTMX*classes directly.
Loading a level
Preload the map and everything it references — the .tmx, any external
.tsx tilesets, and the tileset images:
await loader.preload([
{ name: "map1", type: "tmx", src: "data/map/map1.tmx" },
{ name: "tileset", type: "tsx", src: "data/map/tileset.tsx" },
{ name: "tiles", type: "image", src: "data/img/tiles.png" },
]);
level.load("map1"); // inside Stage.onResetEvent
Asset type is "tmx" for maps and "tsx" for external tilesets — those are
the only two type strings the loader knows. The file can be .tmx / .tsx
(XML), or .json / .tmj / .tsj; the parser branches on the extension, not
on the type. type: "tmj" throws unknown or invalid resource type. You can
also skip src and pass the map inline via data (with format: "json" or
"xml").
level.load(levelId, options) accepts container (default game.world),
onLoaded (default game.onLevelLoaded), flatten (default game.mergeGroup),
setViewportBounds (default true) and async (default false). It throws
level <id> not found for an unknown id — synchronously, in both forms, because
that is a typo rather than a load failure.
Those game. defaults are the engine's own, and game is whichever
Application finished init() last. Pass container explicitly from a
Stage, which has the right one: level.load("map", { container: this.app.world }).
level.load is deferred while the game loop is running. It calls
state.stop() and finishes the load on a timer, after the current frame, so by
default it returns true before anything is in the world. Two ways to sequence
work after it:
// await it
await level.load("map1", { async: true });
// the world is populated here
// ...or use the callback / event, which fire in both forms
level.load("map1", { onLoaded: () => this.spawnPlayer() });
async: true is the only thing that changes the return value — everything else
behaves identically, onLoaded included. Without it the call returns a boolean,
so await level.load("map1") is not an error and does not await the load:
await true resolves immediately, while the load is still sitting on a timer.
Pass the flag when you mean to await.
level.reload(), level.next() and level.previous() take the same async
option and resolve the same value they return — so if (level.next()) becomes
if (await level.next({ async: true })). Running out of levels reports false
either way rather than throwing. level.getCurrentLevelId() and
level.levelCount() round out the namespace. flatten: false wraps each Tiled
object group in its own Container named after the group.
Spawning entities from Tiled objects
Objects are matched against a factory registry, in this order: the object's
Tiled class, then its name, then, for a tile object with no class of
its own, its tile's class, then the structural fallbacks "text",
"tile" and "shape".
import { registerTiledObjectClass, registerTiledObjectFactory } from "melonjs";
registerTiledObjectClass("Enemy", Enemy); // ← matches Tiled class OR name
registerTiledObjectFactory("Spine", (settings, map) => { /* → Renderable */ });
level.load("map1");
These are the entry points to use. The registry is Tiled's own, held by the object factory, and has nothing to do with object pooling.
pool.register(className, classObj) also works and registers a Tiled
factory as a side effect, under the name and again under an me.-prefixed
alias, unless you set pool.autoRegisterTiled = false. That is the older
spelling, kept working for maps and games written against it, and it now
prints a one-off deprecation notice: me.pool is deprecated since 18.0.0.
Its third argument no longer buys anything here. It used to make Tiled
objects recyclable; they are constructed directly now, and the container
returns children to typed pools rather than to the name-keyed one. To pool a
class you spawn constantly, give it a createPool and register it for Tiled
separately:
registerTiledObjectClass("mainPlayer", PlayerEntity);
Register before loading. With no match the object falls through to the
structural factory and becomes a plain Renderable with a static body — it does
not e
Häufige Fragen
Warum lädt mein Level nicht?
Die Fähigkeit sagt, die Karte und alle Tilesets und Bilder, die sie nutzt, müssen zuerst vorgeladen werden.
Welche Kartendateitypen funktionieren?
Die Fähigkeit sagt, die Karte kann in Tiled-XML- oder JSON-Form vorliegen.
Kann sie komprimierte Karten verarbeiten?
Die Fähigkeit sagt, komprimierte Karten brauchen ein zusätzliches Dekomprimierungs-Plugin.
Details
Originalbeschreibung des Autors
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,
repo: melonjs/melonJS
Beliebtheit
- GitHub-Sterne
- 6.4k
- Platz im Ranking
- #14216
- Lizenz
- MIT
- Aktualisiert
- 2.11.2026
Kommentare
- …
Weitere Skills aus diesem Repository
melonjs-20-migration
6.4kHilft deinem Agenten, melonJS-Spielcode für Version 20 zu schreiben und veraltete Methoden aus älteren Versionen zu vermeiden, etwa den nun nötigen asynchronen Start.
melonjs-3d-assets
6.4kHilft deinem Agenten, 3D-Modelle wie glTF-, GLB- und OBJ-Dateien in ein melonJS-Browserspiel zu laden, mit Optionen für Maßstab und Beleuchtung.
melonjs-3d
6.4kHilft deinem Agenten, 3D- oder 2,5D-Szenen in einem melonJS-Browserspiel zu bauen, mit Kameras, Meshes, Lichtern und Tiefe, unter Beachtung der eigenen Achsenregeln der Engine.
melonjs-audio
6.4kHilft deinem Agenten, Soundeffekte und Musik in ein melonJS-Spiel einzubauen, einschließlich Audio-Einrichtung, Hintergrundmusik, Lautstärkeregelung und räumlichem Klang.
Ähnliche Skills
diffs
394kLässt deinen Agenten einen echten, teilbaren Diff seiner Änderungen als Viewer-Link oder Bilddatei erstellen, statt einer handgeschriebenen Zusammenfassung.
coding-agent
394kHilft deinem Agenten, eine größere Programmieraufgabe als Hintergrund-Worker an Codex, Claude Code oder OpenCode zu übergeben und danach den Fortschritt zu prüfen.
gh-issues
394kHilft deinem Agenten, GitHub-Issues zu finden, die zu bearbeitenden auszuwählen und Pull Requests mit Korrekturen zu öffnen, einschließlich der Nacharbeit an Review-Kommentaren.