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.

See: game

Constructor


new Application(width: number, height: number, options: Application.Settings) → {}
Parameters:
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


Methods from Application

draw()

draw the active scene/stage associated to this game

HTMLElement
getParentElement()
init(width: number, height: number, options: Application.Settings)
onLevelLoaded()
repaint()

force the redraw (not update) of all objects

reset()
update(time: number)
updateFrameRate()

Public Properties


isInitialized application.js:70
isInitialized: boolean = false

boolean

true when this app instance has been initialized

lastUpdate application.js:61
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 application.js:53
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 application.js:28
parentElement: HTMLElement

HTMLElement

the parent HTML element holding the main canvas of this application

pauseOnBlur application.js:83
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 application.js:34
renderer: CanvasRenderer | WebGLRenderer

CanvasRenderer | WebGLRenderer

a reference to the active Canvas or WebGL active renderer renderer

resumeOnFocus application.js:93
resumeOnFocus: boolean = true

boolean

Specify whether to unpause this app when gaining back focus

settings application.js:77
settings: Application.settings

Application.settings

the given settings used when creating this application

sortOn application.js:301
sortOn: string

string

Specify the property to be used when sorting renderables for this application game world. Accepted values : "x", "y", "z", "depth"

See: World.sortOn
stopOnBlur application.js:100
stopOnBlur: boolean = false

boolean

Specify whether to stop this app when losing focus

viewport application.js:40
viewport: Camera2d

Camera2d

the active stage "default" camera

world application.js:46
world: World

World

a reference to the game world,
a world is a virtual environment containing all the game objects

Public Methods


draw application.js:404
draw() → {}

draw the active scene/stage associated to this game

getParentElement application.js:343
getParentElement() → {HTMLElement}

Returns the parent HTML Element holding the main canvas of this application

Returns:
Type Description
HTMLElement

the parent HTML element

init application.js:136
init(width: number, height: number, options: Application.Settings) → {}

init the game instance (create a physic world, update starting time, etc..)

Parameters:
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 application.js:314
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);
repaint application.js:351
repaint() → {}

force the redraw (not update) of all objects

reset application.js:283
reset() → {}

reset the game Object manager destroy all current objects

update application.js:358
update(time: number) → {}

update all objects related to this game active scene/stage

Parameters:
Name Type Description
time number

current timestamp as provided by the RAF callback

updateFrameRate application.js:323
updateFrameRate() → {}

Update the renderer framerate using the system config variables.

See:

Powered by webdoc!