Class: Game

Core.Game

Game is the engine's game object to interface with.

new Core.Game (canvasWidth, canvasHeight, fps, assetDir)

Name Type Description
canvasWidth Number The width of the game canvas
canvasHeight Number The height of the game canvas
fps Number The frames per second to lock to
assetDir String The assets directory

Members

assetManager Resources.AssetManager

assetManager

guiManager UI.GuiManager

gui manager

inputManager Input.InputManager

input manager

resourceManager Resources.ResourceManager

resource manager

sceneManager Scene.SceneManager

sceneManager

state String

current state

Methods

getCanvasHeight ()Number

getCanvasHeight get game canvas height
Returns:
Type Description
Number the canvas height

getCanvasWidth ()Number

getCanvasWidth get game canvas width
Returns:
Type Description
Number the canvas width

getCurrentScene ()Scene.Scene

gets the current scene
Returns:
Type Description
Scene.Scene the current scene

logAndStop ()

Logs and stops the game.

renderLoop ()

(internal) Synchronized render loop

renderText (x, y, txt, style, font)

renderText renders text to canvas
Name Type Description
x Number position to render text to
y Number position to render text to
txt String the text to render
style String 2d context style, can be also color description (e.g: "#fff")
font String 2d context font string
Returns:
null

setup ()

Setup initiate the game object. Should be called after document body has been loaded.
Returns:
null

start (update, automated)

Start - start the game engine
Name Type Description
update function the update function (called each engine step)
automated Boolean set whether the engine should automate update & render

stop ()

Stop - stops the game engine
Returns:
null

updateLoop ()

(internal) fast as possible update loop

warn (msg)

warns if in debug mode
Name Type Description
msg String warning message