/melonjs:melonjs-scenes-and-statefrom melonjs
Guides scene structure and game flow in melonJS: Stage subclasses, state manager, transitions, pausing, update loop, timers, tweens, and save/load persistence.
Ships in melonjs. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
A Stage is a screen. Register it against a state id, then change to it:
import { Stage, state } from "melonjs";
class PlayScreen extends Stage {
onResetEvent(app) { /* build the scene */ }
onDestroyEvent(app) { /* tear it down */ }
}
state.set(state.PLAY, new PlayScreen()); // register first
state.change(state.PLAY); // then switch
Built-in ids: state.LOADING, state.MENU, state.READY, state.PLAY,
state.GAMEOVER (no underscore), state.GAME_END, state.SCORE,
state.CREDITS, state.SETTINGS, state.DEFAULT. state.USER (100) is the
base for your own ids — const CUTSCENE = state.USER + 1.
Build scene content in onResetEvent, not the constructor. onResetEvent
runs on every entry to the state; the constructor runs once. Scene content
created in the constructor exists once and is not rebuilt when you return.
onResetEvent(app) receives the Application — use that rather than importing
the global game.
Extra arguments to state.change are forwarded:
state.change(state.PLAY, false, { level: 2 }); // → onResetEvent(app, { level: 2 })
The second argument is forceChange: pass true to switch immediately instead
of on a deferred tick, which is what you want when changing state right after a
preload completes. It is ignored when a transition is configured — a transition
always drives the switch from its own completion callback.
onResetEvent runs when the switch is made. The first frame, STATE_CHANGE and
a transition's reveal follow once the shaders the stage queued are ready, which
is a few milliseconds once the browser has compiled them before, and at most
1.5s on a first visit. So build the stage in onResetEvent: an object a
STATE_CHANGE listener adds is not waited for, and its first draw may still
compile what it needs. That first frame steps the world once before drawing it,
however short it is, so everything onResetEvent added is in it (the same goes
for the frame after a level.load made while the game runs). Before 20.12 it
was drawn unstepped, and showed the stage's background alone for one frame.
state.change throws Undefined Stage for state '<id>' if nothing was
registered for that id, and state.set throws if the second argument is not a
Stage instance. Neither fails quietly.
A change to the state that is already current does nothing: no
onDestroyEvent, no onResetEvent, no transition. So a "Retry" that calls
state.change(state.PLAY) from PLAY is ignored. Build the current stage
again with state.reload() (since 20.16): onDestroyEvent, the world reset and
onResetEvent, with the arguments the state was entered with, or new ones.
level.reload() reloads just the Tiled map, keeping the stage.
// "Play again" on the game-over card, from inside PLAY
new UITextButton(x, y, { text: "AGAIN", onClick: () => state.reload() });
// restart on another level: replaces the arguments for later reloads too
state.reload(false, { level: 2 });
Like state.change, it waits for the next frame unless forceChange is
true, and it throws when no state has been entered yet. It plays no
transition.
state.LOADING — it is transitionalloader.preload() switches to state.LOADING for you. Building your scene in
the preload callback and then staying there looks like it works, and is one
of the easiest mistakes to make:
// WRONG — the game now runs inside the loading stage, forever
loader.preload(assets, () => {
app.world.addChild(new Player(...));
});
Nothing ever destroys that stage, so the built-in loading screen's logo and progress bar are never removed and sit on top of your game. (Eight of this repository's own examples did this before it was noticed, so it is not an obscure trap.)
Give the scene a stage of its own and switch to it:
class PlayScreen extends Stage {
onResetEvent(app) {
app.world.addChild(new Player(...));
}
}
await loader.preload(assets);
state.set(state.PLAY, new PlayScreen());
state.change(state.PLAY);
The awaited form reads better here than the callback, because "load, then
switch" is exactly what the code then says. If you genuinely want to keep using
the loading stage as your scene, state.change(state.DEFAULT) at least gets
you out of it — but a stage of your own is what you want.
if (typeof this.HUD === "undefined") {
this.HUD = new Container(); // construct once (or UIBaseElement)
}
this.HUD.isPersistent = true; // survives level changes
this.HUD.floating = true; // screen coordinates, not world
app.world.addChild(this.HUD, 100); // explicit z — see melonjs-renderables
Everything inside a persistent container is kept with it, physics bodies included (before 20.13 the children's bodies were dropped by the reset).
state.transition("fade", "#FFFFFF", 250);
state.transition("mask", "#000", 500, new Ellipse(0, 0, 1, 1)); // shape required
state.transition("mask", "#000", 500, "star_mask"); // a preloaded image's silhouette
state.transition("mask", "#000", 500, player, { center: player }); // the player's shape, closing on it
state.transition("mask", "#000", 400, new Ellipse(0, 0, 1, 1), { center: player, invert: true });
state.transition("pixelate", "#000", 300); // blocks up to 32px; a 4th argument sets the size
state.pause(); // freeze update, keep drawing
state.resume();
app.freeze(150); // brief hit-stop (proxies state.freeze)
state.transition is global and sticky — once set it applies to every later
state.change; state.setTransition(id, false) turns it off for changes
into one state.
The duration (1000 ms when omitted) is for each half: the cover, then the
reveal. The "mask" form needs its fourth argument, the shape: an Ellipse
or Polygon (unit-sized, centred on the origin), an image or the name of a
preloaded one (its silhouette: transparent pixels are covered, the rest shows
the scene; colours do not matter and gaps inside the outline are filled), or a
Sprite (the silhouette of the frame it shows, facing its way). Without a
shape it warns and falls back to a direct switch. Its fifth argument is
{ center, invert }: center is where the shape closes and the reveal opens,
a renderable (where it is drawn on screen as the transition starts) or a
screen point, the centre of the screen by default; invert: true makes the
shape the cover, filled with the colour and growing out of center. The
shape grows about its thickest part (a U or a sprite drawn off-centre in its
frame too), until the screen is wholly inside it, so the reveal ends with the
scene uncovered.
A sprite or renderable given here is read when the transition starts, and the reveal reuses what the hide read, so the old stage destroying the player in between is fine. Whether it is kept depends on whose it is:
atlas.createSpriteFromName("logo"), or a persistent one in the world): set
it once, it shapes every change, with the frame it shows by then.state.change.// once, at startup: every change wears the logo
state.transition("mask", "#000", 500, atlas.createSpriteFromName("logo"));
// before each change: this level's player
state.transition("mask", "#000", 500, player, { center: player });
state.change(state.GAME_END);
The "pixelate" form breaks the screen up into blocks (its fourth argument is the
largest block size in pixels; the color is not used). It is a shader effect,
so on Canvas it does nothing and the state changes directly.
A level change is not a state change, so state.transition does not apply to
it. A Tiled Trigger that loads a level has a transition of its own, set on
the trigger: color and duration (both needed, or the level loads with
none), and transition: "fade" (the default) or "mask" with a shape,
plus center and invert as above. On a trigger, shape: "touching" and
center: "touching" mean whoever walked in: the player's own silhouette
closing on the player, with no code to find it. A "mask" without a shape
fades instead, without a warning, and there is no pixelate form for a
trigger. See melonjs-tilemaps.
A state.change asked for while a transition covers the screen (Enter pressed
twice on a menu, a timer firing as the player skips a screen) needs no guard:
the transition already under way makes it, switching to the last state asked
for with the last arguments, and a second cover never goes up. A change to a
state with no transition of its own (state.setTransition(id, false)) is made
at once, and the cover comes down with it. Before 20.12 the second change left
the first cover on the camera for good, the screen black over a running game.
update() is NOT pausedThis one is easy to get wrong and hard to see. Application.update calls both
of these unconditionally:
this.isDirty = this.world.update(this.updateDelta);
this.isDirty = state.current().update(this.updateDelta) || this.isDirty;
Only Container.update consults the pause — it reads state.isPaused() and
skips every child that is not updateWhenPaused. So world children (entities,
sprites, meshes, a GLTFModel) freeze correctly, while the Stage subclass's
own update() keeps running. (event.GAME_UPDATE is not emitted while
paused, so logic hung off it stops with the world.)
A game that keeps its logic in entities pauses for free and never notices. A
game that drives the simulation from Stage.update — common for an endless
runner, where one object moves and the world scrolls past it — keeps simulating
through pauseOnBlur with its world frozen. The signature is bizarre and very
misleading: the scenery scrolls on, the player character stands still in world
space and slides off the screen, and it all snaps back on focus. It reads as a
culling or animation bug, not a pause bug.
Guard it explicitly:
update(dt) {
super.update(dt);
if (state.isPaused()) {
return true; // world children are already frozen for you
}
// …simulation…
}
Worth knowing that pauseOnBlur (default true) fires on a window blur, not
only on tab visibilitychange — so clicking another window on the same screen
triggers it while the canvas is still fully visible.
On focus, resumeOnFocus (default true) undoes only the pause the
application applied on blur. A game the player paused from its own menu stays
paused when the window comes back; before 20.9 it resumed underneath the menu.
Who reports the focus, and what the game does. Two separate settings:
| setting | decides | default |
|---|---|---|
device.setFocusEvents() | who reports that the player switched away: the browser window (blur, focus, visibilitychange become event.BLUR / event.FOCUS), or nobody, leaving it to the game's host | the window |
app.pauseOnBlur, stopOnBlur, resumeOnFocus | what the game does on every event.BLUR / event.FOCUS, wherever it comes from | pause on blur, resume on focus |
app.pauseOnBlur = false). The window still reports; nothing pauses.event.BLUR from the host's, so the host's pause would do nothing either.When a host decides, not the window. A game embedded by a host that says
when it runs, such as a web game portal's SDK (YouTube Playables forbids
pausing on the page's visibility) or a native wrapper, stops the window
reporting with device.setFocusEvents(false) and emits the engine's own
events from the host's callbacks:
device.setFocusEvents(false); // the window's blur, focus and visibilitychange no longer count
app.stopOnBlur = true; // a pause stops drawing too; pauseOnBlur keeps drawing
app.pauseOnBlur = false;
ytgame.system.onPause(() => event.emit(event.BLUR));
ytgame.system.onResume(() => event.emit(event.FOCUS));
Everything else is as with the window: pauseOnBlur, stopOnBlur and
resumeOnFocus decide what happens, the sound effects are silenced and held
keys released, and only a pause the engine applied is undone. It can be called
before or after creating the application.
There is no loop you own. Logic goes in update(dt) overrides, or a
GAME_UPDATE subscription for scene-level animation:
event.on(event.GAME_UPDATE, () => { /* per frame */ });
update(dt) must return true when the object changed and needs redrawing.
Returning nothing is falsy and the object can appear frozen while its state moves.
dt is milliseconds since the last frame and is the right basis for motion —
the engine already paces it. Do not reach for performance.now().
Smooth a value toward a target with math.damp, not with lerp per
frame. lerp(current, target, 0.1) once per frame moves further on a slow
frame than on a fast one, so the feel drifts with the frame rate:
this.speed = math.damp(this.speed, targetSpeed, 5, dt / 1000);
damp(current, target, lambda, dt) takes SECONDS, so divide dt. Higher
lambda converges faster. See melonjs-camera-and-drawing for the camera's
own follow() damping, which is already frame-rate independent for you.
A common idiom for a per-frame game controller with nothing to draw is a
Renderable(0, 0, 1, 1) with alwaysUpdate = true and an empty draw().
import { timer } from "melonjs";
timer.setTimeout(fn, 1000);
const id = timer.setInterval(fn, 500);
timer.clearInterval(id); // in the Stage's onDestroyEvent
Stage has only onResetEvent and onDestroyEvent — there is no
onActivateEvent / onDeactivateEvent on a stage. Those two are Renderable
hooks; put per-renderable teardown there instead.
The outgoing stage is destroyed before the incoming one is reset. That
ordering is what makes "each stage owns what it started" work: a scene can
release a resource in onDestroyEvent and the next scene can claim the same
one in onResetEvent without the teardown arriving late and undoing it.
What a stage starts, it must end: input.registerPointerEvent regions,
event.on subscriptions and running Tweens all outlive the stage that made
them. Music is the exception rather than the rule, since audio.playTrack()
stops the track it replaces, so stopTrack() in onDestroyEvent is only
needed where the next screen has no music of its own.
Engine timers are pause-aware. window.setTimeout keeps firing while the
game is paused, which produces enemies spawning behind a pause menu. Pass
false as the third argument — timer.setInterval(fn, 500, false) — for one
that keeps running through a pause, which is what a pause-menu animation or a
countdown that should not freeze needs. (That argument was ignored by
setInterval before 20.3.)
The shape, in any of its spellings. If you are adding a field that counts
milliseconds and dividing it by a constant to get a 0..1, stop:
// ✗ a tween, written out longhand
private flashMs = 0;
// ... in update(dt)
if (this.flashMs > 0) {
this.flashMs -= dt;
const k = this.flashMs / FLASH_MS; // ← the 0..1
effect.setUniform("uIntensity", k * k); // ← and a curve, by hand
}
// ✓ the same thing
const driver = { k: 1 };
new Tween(driver)
.to({ k: 0 }, { duration: FLASH_MS })
.easing(Tween.Easing.Quadratic.In) // the curve, named
.onUpdate(() => effect.setUniform("uIntensity", driver.k))
.start();
The tells, any one of which is enough: a *Ms or *Age field that only
update() touches; a division by a *_MS constant; k * k, (1 - k) ** 2 or
** 1.4 written inline, which is an easing curve spelled by hand; an
if (x <= 0) arm that exists only to clean up at the end, which is
onComplete; a second timer counting the same duration to chain what happens
next, which is delay.
It matters beyond tidiness: a hand-rolled fade needs something to tick it, and
an effect that is NOT a renderable (one living on the camera, say) has nothing
that will. That forces an update(dt) method and a call site in the game loop
whose only job is to drive the fade. A tween updates itself, so both disappear.
Four shapes that look similar and are not tweens:
| shape | what it is | use |
|---|---|---|
| approaching a value that keeps MOVING | a follow, not an animation | math.damp |
| a loop that never ends | oscillation | a sine of your own clock |
| a gate: cooldown, spawn interval, invulnerability window | a timer, nothing is interpolated | a plain countdown |
| the same effect on dozens of live objects | per-instance churn | a hand-rolled countdown really is cheaper |
The rule in one line: fixed duration, known endpoint, one-shot, few instances. All four, or it is not a tween.
import { getPool, Tween } from "melonjs";
const t = getPool("tween").get(sprite.pos) // typed pool, release when done
.to({ x: 300 }, { duration: 500 }) // options object, not a number
.easing(Tween.Easing.Quadratic.Out)
.onComplete(() => { /* … */ })
.start(); // ← without this, nothing happens
Four traps:
.start() (or autoStart: true in the to() options)
silently does nothing.to()'s second argument is an options object
({ duration, easing, yoyo, repeat, delay, repeatDelay, interpolation, autoStart }). Passing a bare number is not a duration — it is read for a
.duration property, finds none, and the tween silently runs the default
1000 ms.state.pause() / freeze() unless
tween.updateWhenPaused = true — which is how you get an effect that decays
through a hit-stop.onUpdate fires against a
dead renderable.A target can be an array: a path. to({ x: [200, 120, 300] }) runs from
the current value through each entry in turn, and
interpolation: Tween.Interpolation.CatmullRom smooths the corners. Each
start() builds the path afresh from the current value, so a replay or a chain
that comes back round runs the same path, and with yoyo the return leg plays
it back the way it came. Before 20.13 a restart ran a longer path each time and
a yoyo path turned the property into NaN.
To animate something that is not a property, tween a holder and push the
value in onUpdate. A shader uniform and a light's intensity are both set
through a method, so there is nothing for to() to interpolate directly. The
callback is invoked with the tweened object as this and the eased progress
0..1 as its argument:
const fade = { level: 1 };
getPool("tween").get(fade)
.to({ level: 0 }, { duration: 400 })
.easing(Tween.Easing.Quadratic.Out)
.onUpdate(function () {
effect.setUniform("uIntensity", this.level);
muzzleLight.intensity = this.level * 3;
})
.start();
Use a function, not an arrow, if you want this to be the tweened object;
an arrow keeps the enclosing this and you read the holder by name instead.
For a handful of pooled objects a hand-rolled countdown in update() is
cheaper than a Tween each — this is the right tool for one-off effects, not
for every particle.
Eleven families, each with In, Out and InOut. Out is what most UI
wants: the value arrives decisively instead of creeping in. The two worth
knowing by name beyond the power curves:
| family | what it does |
|---|---|
Back | overshoots past the target and settles back, which is impact: a stamp, a button press, anything that should LAND rather than arrive |
Bounce | lands and bounces, for something dropping onto a surface |
// a stamp: scale falls to 1 and springs through it
const driver = { scale: 5 };
new Tween(driver)
.to({ scale: 1 }, { duration: 420 })
.easing(Tween.Easing.Back.Out)
.onUpdate(() => { label.currentTransform.identity(); label.scale(driver.scale); })
.onComplete(() => camera.shake(12, 400)) // the thump, when it truly lands
.start();
Back and Elastic leave the range between your start and end, so clamp
anything that cannot take it, an opacity or a colour channel above all. The
overshoot follows the direction of travel: a value tweened DOWN overshoots
below its target.
Reach for onComplete for anything that must happen on arrival, rather than a
second timer counting the same duration. delay in the to() options chains
the next one without a timer either.
Callbacks can fire while a stage is being torn down, when the current state is already something else:
if (!state.isCurrent(state.PLAY)) return;
Without the guard, a "children emptied" handler can reset the wrong stage.
import { save } from "melonjs";
save.add({ hiscore: 0 }); // once; idempotent, loads any stored value
save.hiscore = 1200; // plain assignment writes to localStorage
save.remove("hiscore"); // gone from localStorage; set it again to save it again
In TypeScript, keep what add() returns. The namespace carries a
[key: string]: unknown index for keys registered anywhere, so reading
save.hiscore off it gives you unknown. add() hands back the same
namespace typed with the keys you just registered, which is the handle to
keep:
const store = save.add({ hiscore: 0, lives: 3 });
store.hiscore = 1200; // number, no cast
if (score > store.hiscore) { /* ... */ }
Chained calls accumulate, so save.add({ a: 0 }).add({ b: "" }) is typed with
both.
No localStorage, no error. Where there is none, or reading it throws (a
sandboxed iframe such as an embedded playable page, cookies blocked), save
keeps the keys in memory for the session: add, reads and writes all work,
and nothing outlives the page. No try / catch is needed around it;
device.localStorage is false when the keys will not be kept.
Somewhere other than localStorage. Two calls, one for each kind of
storage:
| call | for |
|---|---|
save.setStorage(storage) | keeping the keys in anything with getItem, setItem and removeItem (the SaveStorage type), called synchronously, as localStorage is |
save.createCloudStorage({ data, write }) | making such a storage out of a platform's cloud save (YouTube Playables, Facebook Instant Games), which loads and saves asynchronously |
localStorage stays the default, and save.setStorage(localStorage) goes back
to it. A storage is handed the same items localStorage would hold:
me.save.<key> with the key's value as JSON, and me.save, the list of keys.
A platform's cloud save: load it before the game reads save, then hand it
over. data is what the platform loaded (an object, its JSON, or nothing the
first time); write(items) saves every item back:
// YouTube Playables: the save is one string
const cloud = save.createCloudStorage({
data: await ytgame.game.loadData(),
write: (items) => ytgame.game.saveData(JSON.stringify(items)),
});
save.setStorage(cloud);
ytgame.system.onPause(() => cloud.flush()); // save at once when the game is paused
// Facebook Instant Games: the save is a key of the player's data
const { save: data } = await FBInstant.player.getDataAsync(["save"]);
save.setStorage(save.createCloudStorage({
data,
write: (items) => FBInstant.player.setDataAsync({ save: items }),
}));
// either way, the game then just uses save
const progress = save.add({ hiscore: 0 }); // the cloud value, or 0 the first time
progress.hiscore = 4200; // saved to the cloud
What createCloudStorage() does for you:
save never waits on the network.write().
Writes are made one at a time: what changes during a write goes in the
next one, with the latest values. A platform that refuses a save while one is
pending (Facebook's PENDING_REQUEST) never sees two.flush().flush() saves now and resolves once everything is saved: call it on the
platform's pause or close.A storage of your own, such as a native wrapper's, only needs the three calls, synchronous:
save.setStorage({
getItem: (key) => native.read(key) ?? null,
setItem: (key, value) => native.write(key, value),
removeItem: (key) => native.erase(key),
});
save.setStorage(localStorage); // and back to the default
When setStorage() switches storage:
add() that it does not hold keeps its value and is written to it, so
setStorage() works before or after add(). A key that was only read from
the previous storage, never registered, is not carried over.| symptom | cause |
|---|---|
| scene builds once and is empty on return | content created in the constructor, not onResetEvent |
a cloud save behind save.setStorage() comes back with the defaults | the storage answered before its data had loaded; await the platform's load, then save.createCloudStorage({ data, write }) |
the platform refuses saves (Facebook's PENDING_REQUEST), or the game floods it with them | a hand-written storage saving on every setItem(); save.createCloudStorage() saves the changes together, one write at a time |
| progress made just before the player left is lost | the last save was still waiting; call the cloud storage's flush() on the platform's pause |
a saved key is gone after save.setStorage() | only keys registered with save.add() are carried over to the new storage; register it (before or after) |
| the high score is back at its default on every visit, with no error | there is no localStorage there (a sandboxed iframe, cookies blocked), so save kept it in memory; device.localStorage is false, and save.setStorage() can keep it elsewhere |
| the game pauses or goes quiet when the tab is hidden, on a portal that must decide that itself | the window still drives the focus: device.setFocusEvents(false), then emit event.BLUR / event.FOCUS from the portal's callbacks |
| a host's pause stops the game's updates but it keeps drawing | pauseOnBlur keeps drawing; set stopOnBlur = true and pauseOnBlur = false |
a host's pause does nothing, after turning pauseOnBlur off so the tab would not pause the game | the flags apply to every event.BLUR, the host's included; keep them, and stop the window reporting with device.setFocusEvents(false) |
Undefined Stage for state 'N' thrown | no state.set for that id first |
state.change(state.PLAY) from PLAY does nothing ("Retry" ignored) | a change to the current state is a no-op — state.reload() (20.16), level.reload() for the map alone |
| a mask transition closes on the middle of the screen, not on the player | pass { center: player } as the fifth argument; on a Trigger, center: "touching" |
the first mask transition is the player's shape, later ones a plain iris on the middle of the screen, the console saying the sprite shaping the mask transition went with its level (20.17) | a sprite that is part of the level is destroyed by the change, so state.transition lets it go after one transition: set it again, with this level's player, right before each state.change. A sprite kept outside any level (or a persistent one) is set once and shapes every change |
a level change through a Trigger ignores state.transition | it is a level change, not a state change: set color and duration (and transition) on the trigger |
| the game stops updating for good after one very slow update, such as a heavy first frame (20.12 and 20.13) | the loop could no longer save enough time to step the world: update |
| the game resumes under its own pause menu after a tab switch (before 20.9) | focus undid any pause; update, only the blur pause is undone |
| a tween finishes in 1000 ms whatever you pass | to() takes { duration }, not a number |
| object frozen while its state updates | update() not returning true |
| timers fire behind a pause menu | window.setTimeout instead of timer.setTimeout |
| the world freezes on blur but the game keeps advancing | simulation lives in Stage.update, which the pause does not gate — only Container.update checks state.isPaused() |
| the player character is left behind and scrolls off after a lost window | same cause: the stage advanced the camera while its world children were paused |
| a tween does nothing | .start() never called |
an array (path) tween wanders further on each replay, or goes NaN with yoyo | before 20.13 start() re-prepended the start value to the path and yoyo swapped the array into the start value; upgrade |
a repeating or yoyo tween runs a single cycle when started again (a pulse pulses once, a yoyo stays at the far end) | before 20.13 start() did not restore the repeat count the first run had used up; upgrade |
| effect stops during a hit-stop | tween needs updateWhenPaused = true |
| crash after a stage switch | callback ran during teardown — guard with state.isCurrent |
| HUD scrolls away with the camera | missing floating = true |
a save key set again after save.remove() reads back fine, then is gone (or back at its default) after a reload (before 20.13) | the write skipped the list of keys restored at boot; update |
melonjs-getting-started — the Application and the first scenemelonjs-renderables — floating, draw order, update/draw contractsWhat SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
melonjs, game-state, scene-management, transitions, tweens, save-system
npx claudepluginhub melonjs/melonjs --plugin melonjs27 skills in this plugin
/melonjsUse this skill FIRST for any melonJS task, and when asked to build a game for the browser with no engine named; it says what melonJS is the right engine for, turns a game idea into a plan, and routes to the right specialised skill. melonJS is an open-source 2D, 2.5D and 3D HTML5 game engine running on WebGPU, WebGL 2 or Canvas, with no runtime dependencies. Covers Application setup, the scene graph, renderables, sprites, tilemaps, physics, audio, particles, shaders, and the 3D tier — perspective cameras, meshes and glTF scenes. Triggers on: melonjs, melonJS, me.game, Application, app.init, app.world, Renderable, Sprite, Stage, state.change, Camera2d, Camera3d, Mesh, tilemap, Tiled, TMX, ParticleEmitter, ShaderEffect, make a game, build a game, browser game, web game, HTML5 game, HTML5 game engine, JavaScript game, TypeScript game, 2D game, platformer, top-down game, puzzle game, shooter, arcade game, game jam, playable ad, which game engine./melonjs-20-migrationUse this skill when writing melonJS code that may be based on pre-20.x knowledge, when migrating a game from melonJS 19.x or earlier, or when an API you expected does not exist. Covers the mandatory async Application.init(), the WebGL 2 baseline and WebGPU backend, renderable post effects replacing the shader property, the deprecated exports still present, and what changed again during 20.x. Triggers on: migration, upgrade, melonJS 19, me.game, me.video.init, video.renderer, renderable.shader, Compositor, CanvasTexture, me.Math, pool.pull, pool.register, world.adapter, uvOffset, deprecated./melonjs-3dUse this skill for anything 3D or 2.5D in melonJS — Camera3d, Mesh, InstancedMesh, Sprite3d billboards, Light3d, ground shadows, glTF/GLB scenes, and depth sorting. Covers the Y-down/+Z-forward convention (OpenGL's inverse), the cameraClass opt-in, orthographic (isometric) projection, clip planes, and the Canvas fallback's limits. Triggers on: Camera3d, toon, cel shading, toonBands, outlineWidth, outlineMode, rimLight, orthographic, isometric, orthoHeight, orthoWidth, projection, Mesh, InstancedMesh, Sprite3d, Trail3d, Light3d, billboard, glTF, glb, 3D, 2.5D, depth, cameraClass, fov, setClipPlanes, setFog, fog, heightFalloff, transparent, transparency, blendMode, castGroundShadow, shadowGroundPoint, lit, emissive, specular, shininess, normalMap, alphaCutoff, depthTest, vertexColors, worldToScreen, screenToRay, screenToWorld, pick, pickable, Ray3d, intersectRay, hit3d, followOffset, setBasis, getBasis, lookAt, orbit, up vector, gimbal, slerp, turn a direction, physics, rapier3d, Capsule3d, TriangleMesh3d./melonjs-3d-assetsUse this skill when loading 3D models into melonJS — glTF and GLB scenes, OBJ/MTL models, materials, imported lights, node animation, skinned characters, crossfades and attachments, ground shadows and GPU instancing. Covers level.load options including the async flag, the rightHanded conversion, and exactly what the loader does and does not support. Triggers on: glTF, gltf, glb, OBJ, MTL, 3D model, getGLTF, getOBJ, getMTL, GLTFModel, GLTFScene, level.load glb, rightHanded, lightIntensityScale, castGroundShadow, shadowGroundY, EXT_mesh_gpu_instancing, KHR_lights_punctual, alphaMode, doubleSided, map_d, map_bump, normalize, animationspeed, skinning, skinned mesh, skin, JOINTS_0, WEIGHTS_0, rigged character, Mixamo, crossfade, blend animations, reverseAnimation, setAnimationTime, play backwards, attach to bone, addChildToNode, getNodeTransform, getNodeNames, Blender export, 3D asset./melonjs-audioUse this skill for sound and music in melonJS — loading audio, playing effects, background tracks, audio sprites, volume and muting, spatial audio, procedural tone/noise generation, and effects such as reverb or a compressor on the whole mix. Covers the mandatory audio.init format list, the directory-not-file src convention, playTrack versus play, the fixed listener and pixel-scale distances of positional sound, and browser autoplay unlocking. Triggers on: audio, sound, audio.init, audio.play, playTrack, stopTrack, audio.load, sfx, music, volume, mute, fade, rate, pitch, sprite audio, stereo, panner, position, listener, refDistance, reverb, echo, delay, compressor, distortion, filter, audio effect, audio.tone, audio.noise, getAudioContext, getMasterGain, hasAudio, hasFormat, autoplay, no sound, sound stopped working, context suspended, silent after idle, clips silent but tones play./melonjs-camera-and-drawingUse this skill for camera control and immediate-mode drawing in melonJS — following a target, viewport bounds, shake and fade, secondary cameras and what each one draws, and drawing shapes, lines and gradients inside a custom draw(). Covers world versus screen coordinate conversion, clipping and masking, baking with CanvasRenderTarget, and reading pixels back. Triggers on: Camera2d, viewport, follow, offset, look ahead, setBounds, minimap, second camera, split screen, cullMask, visibilityLayer, hide from a camera, zoom, roll, shake, fadeIn, fadeOut, CameraEffect, addCameraEffect, MaskEffect, iris, image mask, PixelateTransitionEffect, worldToLocal, localToWorld, worldToScreen, screenToRay, screenToWorld, colorMatrix, renderer.fill, renderer.stroke, setGlobalAlpha, fillArc, Rect, Ellipse, Polygon, Line, Path2D, SVG path, Gradient, clipRect, mask, CanvasRenderTarget, NoiseTexture2d, lookAt, setBasis, orbit, toImageData, getImageData, toBlob, toDataURL, screenshot, read pixels.Other plugins' skills for the same job