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.
Summary
Properties from Application
DOMHighResTimeStamp |
|
boolean |
|
string |
|
Camera2d |
|
World |
|
Methods from Application
|
|
Container |
|
init the game instance (create a physic world, update starting time, etc..) |
|
|
|
force the redraw (not update) of all objects |
|
|
|
|
|
|
Public Properties
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: 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: string = "z"
Specify the property to be used when sorting renderables. Accepted values : "x", "y", "z"
viewport: Camera2d = undefined
a reference to the current active stage "default" camera
world: World = undefined
a reference to the game world,
a world is a virtual environment containing all the game objects
Public Methods
draw(stage: Stage) → {}
draw the active scene/stage associated to this game
Name | Type | Description |
---|---|---|
stage | Stage |
the current stage |
getParentContainer(child: Renderable) → {Container}
Returns the parent container of the specified Child in the game world
Name | Type | Description |
---|---|---|
child | Renderable |
Type | Description |
---|---|
Container |
init() → {}
init the game instance (create a physic world, update starting time, etc..)
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, stage: Stage) → {}
update all objects related to this game active scene/stage
Name | Type | Description |
---|---|---|
time | number |
current timestamp as provided by the RAF callback |
stage | Stage |
the current stage |
updateFrameRate() → {}
Update the renderer framerate using the system config variables.
- timer.maxfps
- World.fps