Skip to content
Henryk Wollik edited this page Jul 29, 2014 · 2 revisions

Class: App

App

new App(canvas) → {App}

Base class for all Foam applications.

Parameters:
Name Type Argument Description
canvas HTMLCanvasElement <optional>

Target canvas

Source:
Returns:
Type
App

Members

<protected> _gl :CanvasRenderingContext2D

Reference to WebGLRenderingContext

Type:
  • CanvasRenderingContext2D
Source:

<protected> _glDraw :glDraw

Reference to glDraw.

Type:
Source:

<protected> _glTrans :glTrans

Reference to glTrans

Type:
Source:

Methods

<static> getInstance() → {App}

Get an instance of the current program.

Source:
Returns:
Type
App

<static> new(resource, obj)

Factory method. Inititates a program.

Parameters:
Name Type Description
resource Object | Array.<Object>

The resource / resource-bundle {path, type} to be loaded

obj Object

A program object {setup,update}

Source:

<static> newOnLoad(obj)

Factory method. Inititates a program. Called on window load.

Parameters:
Name Type Description
obj Object

A program object {setup,update}

Source:

<static> newOnLoadWithResource(resource, obj, callbackError, {Function), strict)

Factory method. Initiates a program providing loaded resources. Called on window load.

Parameters:
Name Type Argument Default Description
resource Object | Array.<Object>

The resource / resource-bundle {path, type} to be loaded

obj Object

A program object {setup,update}

callbackError function <optional>

Callback if an error occured

{Function)

[callbackProcess] - Callback on load

strict bool <optional>
true

Abort if at least one resource could not be loaded

Source:

<static> newOnResource(resource, obj, callbackError, {Function), strict)

Factory method. Initiates a program providing loaded resources.

Parameters:
Name Type Argument Default Description
resource Object | Array.<Object>

The resource / resource-bundle {path, type} to be loaded

obj Object

A program object {setup,update}

callbackError function <optional>

Callback if an error occured

{Function)

[callbackProcess] - Callback on load

strict bool <optional>
true

Abort if at least one resource could not be loaded

Source:

getFPS() → {Number}

Return the current target framerate

Source:
Returns:
Type
Number

getFramesElapsed() → {Number}

Return the number of frames elapsed since the program started.

Source:
Returns:
Type
Number

getSecondsElapsed() → {Number}

Return the number of seconds elapsed since the program started.

Source:
Returns:
Type
Number

getTime() → {Number}

Return the current time.

Source:
Returns:
Type
Number

getTimeDelta() → {Number}

Return the time the between now and the last update call.

Source:
Returns:
Type
Number

getTimeStart() → {Number}

Return the time at program start.

Source:
Returns:
Type
Number

getWindowAspectRatio() → {number}

Return the current window aspect ratio.

Source:
Returns:
Type
number

getWindowBounds(rect) → {Rect}

Return the current window's bounds.

Parameters:
Name Type Description
rect Rect

Out rect

Source:
Returns:
Type
Rect

getWindowHeight() → {Number}

Return the window´s current height.

Source:
Returns:
Type
Number

getWindowScale() → {number}

Return the current window scale.

Source:
Returns:
Type
number

getWindowSize(v) → {Vec2}

Return the window´s current size.

Parameters:
Name Type Argument Description
v Vec2 <optional>

Out size

Source:
Returns:
Type
Vec2

getWindowWidth() → {Number}

Return the window´s current width.

Source:
Returns:
Type
Number

loop(loop)

Set if the program should continously call update.

Parameters:
Name Type Description
loop Boolean
Source:

<abstract> onWebGLContextNotAvailable()

Callback if webgl is not available.

Source:

onWindowResize()

Callback on window resize.

Source:

setFPS(fps)

Set the target framerate.

Parameters:
Name Type Description
fps Number

The framerate

Source:

<abstract> setup()

Setup

Source:

setWindowSize(width, height, scale)

Set the window size.

Parameters:
Name Type Argument Description
width Number

The width

height Number

The height

scale Number <optional>

The ratio of pixels per window pixel (default: 1:1)

Source:

<abstract> update()

Update

Source:

Generated with wicked.
Clone this wiki locally