Application
class Application
An Application represents a single melonJS game, and is responsible for updating (each frame) all the related object status and draw them.
Constructor
new Application(width: number, height: number, options: Application.Settings) → {}
Name | Type | Attributes | Description |
---|---|---|---|
width | number |
The width of the canvas viewport |
|
height | number |
The height of the canvas viewport |
|
options | Application.Settings |
<optional> |
The optional parameters for the application and default renderer |
Summary
Properties from Application
boolean |
|
DOMHighResTimeStamp |
|
boolean |
|
HTMLElement |
|
boolean |
|
CanvasRenderer | WebGLRenderer |
|
boolean |
|
Application.settings |
|
string |
|
boolean |
|
Camera2d |
|
World |
|
Methods from Application
draw the active scene/stage associated to this game |
|
HTMLElement |
|
|
|
|
|
force the redraw (not update) of all objects |
|
|
|
|
|
|
Public Properties
isInitialized: boolean = false
boolean
true when this app instance has been initialized
lastUpdate: DOMHighResTimeStamp = 0
DOMHighResTimeStamp
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.
mergeGroup: boolean = true
boolean
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
parentElement: HTMLElement
HTMLElement
the parent HTML element holding the main canvas of this application
pauseOnBlur: boolean = true
boolean
Specify whether to pause this app when losing focus
// keep the default game instance running even when loosing focus
me.game.pauseOnBlur = false;
renderer: CanvasRenderer | WebGLRenderer
CanvasRenderer | WebGLRenderer
a reference to the active Canvas or WebGL active renderer renderer
resumeOnFocus: boolean = true
boolean
Specify whether to unpause this app when gaining back focus
settings: Application.settings
Application.settings
the given settings used when creating this application
sortOn: string
string
Specify the property to be used when sorting renderables for this application game world. Accepted values : "x", "y", "z", "depth"
stopOnBlur: boolean = false
boolean
Specify whether to stop this app when losing focus
world: World
World
a reference to the game world,
a world is a virtual environment containing all the game objects
Public Methods
getParentElement() → {HTMLElement}
Returns the parent HTML Element holding the main canvas of this application
Type | Description |
---|---|
HTMLElement |
the parent HTML element |
init(width: number, height: number, options: Application.Settings) → {}
init the game instance (create a physic world, update starting time, etc..)
Name | Type | Attributes | Description |
---|---|---|---|
width | number |
The width of the canvas viewport |
|
height | number |
The height of the canvas viewport |
|
options | Application.Settings |
<optional> |
The optional parameters for the application and default renderer |
onLevelLoaded() → {}
Fired when a level is fully loaded and all renderable instantiated.
Additionnaly the level id will also be passed to the called function.
// call myFunction () everytime a level is loaded
me.game.onLevelLoaded = this.myFunction.bind(this);
update(time: number) → {}
update all objects related to this game active scene/stage
Name | Type | Description |
---|---|---|
time | number |
current timestamp as provided by the RAF callback |
updateFrameRate() → {}
Update the renderer framerate using the system config variables.
- timer.maxfps
- World.fps