Application

class Application

An Application represents a single melonJS game. An Application is responsible for updating (each frame) all the related object status and draw them.

See: game

Summary


Properties from Application

Methods from Application

draw(stage: Stage)
Container
getParentContainer(child: Renderable)
init()

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

onLevelLoaded()
repaint()

force the redraw (not update) of all objects

reset()
update(time: number, stage: Stage)
updateFrameRate()

Public Properties


lastUpdate application.js:48
lastUpdate: DOMHighResTimeStamp = 0

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:30
mergeGroup: boolean = true

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

sortOn application.js:39
sortOn: string = "z"

Specify the property to be used when sorting renderables. Accepted values : "x", "y", "z"

viewport application.js:15
viewport: Camera2d = undefined

a reference to the current active stage "default" camera

world application.js:22
world: World = undefined

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

Public Methods


draw application.js:204
draw(stage: Stage) → {}

draw the active scene/stage associated to this game

Parameters:
Name Type Description
stage Stage

the current stage

getParentContainer application.js:142
getParentContainer(child: Renderable) → {Container}

Returns the parent container of the specified Child in the game world

Parameters:
Name Type Description
child Renderable
Returns:
Type Description
Container
init application.js:83
init() → {}

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

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

force the redraw (not update) of all objects

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

reset the game Object manager destroy all current objects

update application.js:158
update(time: number, stage: Stage) → {}

update all objects related to this game active scene/stage

Parameters:
Name Type Description
time number

current timestamp as provided by the RAF callback

stage Stage

the current stage

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

Update the renderer framerate using the system config variables.

See:

Powered by webdoc!