kick.core.Engine Class
Game engine object
Constructor
kick.core.Engine
-
idOrElement
-
config={}
Parameters:
-
idOrElement
String | Canvaselementid of canvas tag or the canvas element
-
config={}
kick.core.ConfigConfiguration 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>
Item Index
Methods
- _gameLoop
- addContextListener deprecated
- addFrameListener deprecated
- canvasResized deprecated
- createUID
- getGLExtension
- getUID
- init
- isFullScreenSupported
- removeContextListener deprecated
- removeFrameListener deprecated
- setFullscreen
Properties
Methods
_gameLoop
-
time
Parameters:
-
time
Numbercurrent time in milliseconds
addContextListener
-
contextLostListener
Parameters:
-
contextLostListener
Objectimplements contextLost() and contextRestored(gl)
addFrameListener
-
frameListener
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:
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
Get the uid of a component (or creates the uid if not defined)
Parameters:
-
object
Object
Returns:
init
()
private
isFullScreenSupported
()
Returns:
Boolean
removeContextListener
-
contextLostListener
Parameters:
-
contextLostListener
Object
removeFrameListener
-
frameListener
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
canvas
HTML-Element
final
The canvas element (readonly)
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)
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.
version
String
final
The current version of KickJS
Events
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