Engine

Global root object for the entire engine.

Constructor

new Engine()

Create a new Engine.

Members

_app

App for holding game data

_cookies

Global cookie manager

_input

Global input manager

_reg

Registry holder

_spaces

Global space manager

_tasks

Global task manager

app

Get the root application.

colors

Colors to be used throughout the engine.

cookies

Get the global cookie manager.

debug

Global debugging flags. Can be enabled to display debugging information.

flags

Global flags.

fonts

Fonts to be used throughout the engine in drawing on the canvas.

height

Height of the canvas being used.

input

Get the global input handler.

mousePos

The current mouse position relative to the canvas.

reg

Get the registries for holding assets and more.

spaces

Get the global space manager.

tasks

Get the global task manager.

width

Width of the canvas being used.

Methods

createImage(func, onDone, width, height)

Generate an image using a custom function on an offscreen canvas.
Parameters:
NameTypeDescription
funcfunctionFunction to run (passes in context)
onDonefunctionFunction to run when complete (passes in image)
widthnumberWidth of image (starts at x = 0)
heightnumberHeight of image (starts at y = 0)

createImageData(func, width, height) → {ImageData}

Generate image data using a custom function on an offscreen canvas.
Parameters:
NameTypeDescription
funcfunctionFunction to run (passes in context)
widthnumberWidth of data (starts at x = 0)
heightnumberHeight of data (starts at y = 0)
Returns:
Generated image data
Type: 
ImageData

init(canvasID, onload, preload)

Initialize the engine.
Parameters:
NameTypeDescription
canvasIDstringThe ID of the canvas to draw on
onloadfunctionFunction to call once all assets are loaded
preloadfunctionFunction for loading assets

loadDec()

Decrement the amount of assets loading, and start the application if it reaches 0.

loadInc()

Increment the amount of assets loading.