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
State ID (see constants)
OptionalforceChange: boolean = falseif true the state will be changed immediately (without waiting for the next frame)
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 = falsealso 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 = _stateState 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 = falsepause current music track on screen pause
Restart the current stage from a full stop.
Optionalmusic: boolean = falseresume current music track on screen resume
resume the current stage
Optionalmusic: boolean = falseresume 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 = falseif 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 = falsepause current track on screen stop.
a State Manager (state machine)