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: ApplicationSettings) → {}
Parameters:
Name Type Attributes Description
width number

The width of the canvas viewport

height number

The height of the canvas viewport

options ApplicationSettings

<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: ApplicationSettings)
onLevelLoaded()
repaint()

force the redraw (not update) of all objects

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

Public Properties


isInitialized application.js:75
isInitialized: boolean = false

boolean

true when this app instance has been initialized

lastUpdate application.js:66
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:58
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:33
parentElement: HTMLElement

HTMLElement

the parent HTML element holding the main canvas of this application

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

CanvasRenderer | WebGLRenderer

a reference to the active Canvas or WebGL active renderer renderer

resumeOnFocus application.js:98
resumeOnFocus: boolean = true

boolean

Specify whether to unpause this app when gaining back focus

settings application.js:82
settings: ApplicationSettings

ApplicationSettings

the given settings used when creating this application

sortOn application.js:306
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:105
stopOnBlur: boolean = false

boolean

Specify whether to stop this app when losing focus

viewport application.js:45
viewport: Camera2d

Camera2d

the active stage "default" camera

world application.js:51
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:409
draw() → {}

draw the active scene/stage associated to this game

getParentElement application.js:348
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:141
init(width: number, height: number, options: ApplicationSettings) → {}

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 ApplicationSettings

<optional>

The optional parameters for the application and default renderer

onLevelLoaded application.js:319
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:356
repaint() → {}

force the redraw (not update) of all objects

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

reset the game Object manager destroy all current objects

update application.js:363
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:328
updateFrameRate() → {}

Update the renderer framerate using the system config variables.

See:

Powered by webdoc!