API Docs for: 0.5.5
Show:

kick.core.Engine Class

Module: kick.core

Game engine object

Constructor

kick.core.Engine

(
  • idOrElement
  • config={}
)

Parameters:

  • idOrElement String | Canvas

    elementid of canvas tag or the canvas element

  • config={} kick.core.Config

    Configuration object

Example:

 <canvas id="3dCanvas" width="50" height="50"></canvas>
 <script src="require.js"></script>
 <script type="text/javascript">
     var req = require.config({
             paths: {
                 kick: 'kick-debug' // loads kick-debug.js (must be in same path)
             }
         });
     req(['kick'],
             function (kick) {
                 // init engine (create 3d context)
                 var engine = new kick.core.Engine('3dCanvas');
             }
     );
 </script>

Methods

_gameLoop

(
  • time
)
private

Parameters:

  • time Number

    current time in milliseconds

addContextListener

(
  • contextLostListener
)
deprecated

Parameters:

  • contextLostListener Object

    implements contextLost() and contextRestored(gl)

addFrameListener

(
  • frameListener
)
deprecated

Defined in kick/core/Engine.js:352

Deprecated: Use addEventListener("postUpdateListener", frameListener) instead

Add a framelistener. Frame listeners are invoked last thing in update loop.
Frame listener object must define the method frameUpdated()

Parameters:

  • frameListener Object

canvasResized

() deprecated

This method should be invoked when the canvas is resized.
This will change the viewport size of the WebGL state.
Instead of calling this method explicit, the configuration parameter checkCanvasResizeInterval can also be set to support automatically checks

createUID

() Number

Creates a uniq id

Returns:

Number:

uniq id

getGLExtension

(
  • extensionName
)

Query WebGL for a specific extension. If found, the extension object is returned. "WEBKIT_", "MOZ_" vendor prefixes are used.

Parameters:

  • extensionName String

Returns:

Object|null

getUID

(
  • object
)
String

Get the uid of a component (or creates the uid if not defined)

Parameters:

  • object Object

Returns:

String:

init

() private

isFullScreenSupported

()

Returns:

Boolean

removeContextListener

(
  • contextLostListener
)
deprecated

Parameters:

  • contextLostListener Object

removeFrameListener

(
  • frameListener
)
deprecated

Parameters:

  • frameListener Object

setFullscreen

(
  • fullscreen
)

Note that fullscreen needs to be invoked directly from a keyboard event or a mouse event from outside the gameLoop. This means it is currently not possible to set fullscreen from a Component's update method.

Parameters:

  • fullscreen Boolean

Properties

activeScene

kick.scene.Scene

If null then nothing is rendered

canvas

HTML-Element final

The canvas element (readonly)

canvasDimension

kick.math.Vec2

The width and height of the canvas

config

kick.core.Config

Configuration of the engine

eventQueue

kick.core.EventQueue final

gl

WebGLRenderingContext final

The WebGL context (readonly)

glState

kick.core.GLState protected final

The WebGL state(readonly). (Only used to keep track on webgl state across different objects)

instance

kick.core.Engine static

Returns the singleton engine object

keyInput

kick.core.KeyInput

Returns a keyInput object. This object is used to detect key input.

mouseInput

kick.core.MouseInput

Returns a mouseInput object. This object is used to detect mouse input.

paused

Boolean

Controls is the gameloop is running

project

kick.core.Project final

Project describes the resources available for a given projects (such as Scenes, Materials, Shader and Meshes)

resourceLoader

kick.core.ResourceLoader final

Resource manager of the engine. Loads and cache resources.

time

kick.core.Time

Time object of the engine. Is updated every frame

version

String final

The current version of KickJS

Events

canvasResized

Fired when canvas is resized.

Event Payload:

contextLost

Fired when gl-context is lost

contextRestored

Fired when gl-context is restored (after context has been lost).

Event Payload:

  • glContext WebGLRenderingContext

postUpdateListener

Fired after script updates methods has been run invoked

preUpdateListener

Fired before script updates methods has been run invoked