Constdefault state ID for Credits Stage
default state ID for the default Stage (the default stage is the one running as soon as melonJS is started)
default state ID for Game End Stage
default state ID for Game Over Stage
default state ID for Loading Stage
default state ID for Menu Stage
default state ID for Play Stage
default state ID for "Ready" Stage
default state ID for High Score Stage
default state ID for Settings Stage
default state ID for user defined constants
change the game/app state
With a transition (see state.transition), the state changes once the transition covers the screen. A change asked for until then is made by that same transition rather than a second one: it switches to the last state asked for, with the last arguments given. A change to a state whose transition is off (see state.setTransition) does not wait for it, and the cover comes down as the state changes.
State ID (see constants)
OptionalforceChange: boolean = false
if true the state will be changed immediately (without waiting for the next frame); ignored when a transition makes the change
extra arguments to be passed to the reset functions
return a reference to the current stage
useful to call a object specific method
the current Stage instance, or undefined if no stage is active
Freeze the current stage for a fixed duration, then automatically resume. Useful for hit-stop / hit-pause effects on impact.
Behaviour notes:
freeze() is called again while a freeze is already active, the
freeze is extended to whichever end-time is later (calls do not
stack). The music flag from the initial call is preserved.freeze() was called, the freeze
timer will not unpause it on expiry — the game stays paused.state.resume() or state.stop() while a freeze is active
cancels the timer and resolves the returned promise immediately.pauseOnBlur behaviour still
keeps the game paused while away.NaN, and Infinity durations silently no-op.duration of the freeze in milliseconds
Optionalmusic: boolean = false
also pause the current music track during the freeze
a Promise that resolves once the freeze ends (or is cancelled)
returns the stage associated with the specified state (or the current one if none is specified)
OptionalstateId: number = _state
State ID (see constants)
the Stage instance associated with the given state ID, or undefined
return true if the specified state is the current one
State ID (see constants)
true if the specified state is the current one
Return the pause state of the state manager
true if the game is paused
return the running state of the state manager
true if a "process is running"
pause the current stage
Optionalmusic: boolean = false
pause current music track on screen pause
Restart the current stage from a full stop.
Optionalmusic: boolean = false
resume current music track on screen resume
resume the current stage
Optionalmusic: boolean = false
resume current music track on screen resume
associate the specified state with a Stage
State ID (see constants)
Instantiated Stage to associate with state ID
Optionalstart: boolean = false
if true the state will be changed immediately after adding it.
enable/disable the transition to a particular state (by default enabled for all)
State ID (see constants)
true to enable transition, false to disable
Stop the current stage.
OptionalshouldPauseTrack: boolean = false
pause current track on screen stop.
specify a global transition effect
"fade" for a color fade, "mask" for a shape-based mask transition, "pixelate" for the screen breaking up into ever larger blocks, changing behind the largest, and coming back sharp (see PixelateTransitionEffect). A pixelate transition is a shader effect: on the Canvas renderer it does nothing, and the state changes directly.
a CSS color value (not used by "pixelate")
Optionalduration: number = 1000
expressed in milliseconds, for each half: the cover, then the reveal
Optionalshape: number | Polygon | Ellipse
an Ellipse or Polygon defining the mask shape (required when effect is "mask"), or for "pixelate" the size of the largest blocks, in screen pixels (32 by default)
a State Manager (state machine)