Create and initialize a new melonJS Application. This is the recommended way to start a melonJS game.
The width of the canvas viewport
The height of the canvas viewport
The optional parameters for the application and default renderer
true when this app instance has been initialized
Last time the game update loop was executed.
Use this value to implement frame prediction in drawing events,
for creating smooth motion while running game update logic at
a lower fps.
when true, all objects will be added under the root world container.
When false, a me.Container object will be created for each corresponding groups
the parent HTML element holding the main canvas of this application
Specify whether to pause this app when losing focus
a reference to the active Canvas or WebGL renderer
Specify whether to unpause this app when gaining back focus
the given settings used when creating this application
Specify whether to stop this app when losing focus
the active stage "default" camera
a reference to the game world,
a world is a virtual environment containing all the game objects
Destroy this application instance and release all associated resources. Removes the canvas from the DOM, destroys the world, and unregisters all event listeners.
if true, the canvas element is removed from the DOM (default: true)
draw the active scene/stage associated to this game
Returns the parent HTML Element holding the main canvas of this application
the parent HTML element
init the game instance (create a physic world, update starting time, etc..)
The width of the canvas viewport
The height of the canvas viewport
Optionaloptions: Partial<ApplicationSettings>The optional parameters for the application and default renderer
force the redraw (not update) of all objects
reset the game Object manager destroy all current objects
Trigger a manual resize of the application canvas to fit the parent element. This is automatically called on window resize/orientation change, but can be called manually if the parent element size changes programmatically.
update all objects related to this game active scene/stage
current timestamp as provided by the RAF callback
Update the renderer framerate using the system config variables.
The Application class is the main entry point for creating a melonJS game. It initializes the renderer, creates the game world and viewport, registers DOM event listeners (resize, orientation, scroll), and starts the game loop.
The Application instance provides access to the core game systems:
The app instance is automatically passed to Stage#onResetEvent and Stage#onDestroyEvent, and is accessible from any renderable via parentApp.
Example