API Docs for: 1.4.0
Show:

Kiwi.Game Class

Defined in: src\core\Game.ts:9
Module: Kiwi

The base class that is used when you create a new Game. Handles the initialisation of all of the various individual game managers and holds the RAF (RequestAnimationFrame object) which is used for the game loop.

Constructor

Kiwi.Game

(
  • [domParent='']
  • [name='KiwiGame']
  • [state=null]
  • [options]
)
Kiwi.Game

Defined in src\core\Game.ts:9

Parameters:

  • [domParent=''] String optional

    The ID of a DOM element that the game should use as its 'container'. If you are targeting Cocoon then you don't need to worry about this and can leave it blank.

  • [name='KiwiGame'] String optional

    The name of the game that is being created.

  • [state=null] Any optional

    The state to load initially. This can either be the name of a state, but preferably this would be the state object itself.

  • [options] Object optional

    Any special options for the game. E.g. Is DEBUG_ON or DEBUG_OFF, RENDERER_CANVAS or RENDERER_WEBGL, TARGET_BROWSER or TARGET_COCOON

    • [debug=Kiwi.DEBUG_ON] Number optional

      If debugging is enabled or not.

    • [bootCallback=null] Function optional

      A callback to be executed when the game reaches the boot stage.

    • [deviceTarget=Kiwi.TARGET_BROWSER] Number optional

      The type of device Kiwi is being used on.

    • [renderer=Kiwi.RENDERER_AUTO] Number optional

      The renderer Kiwi should use.

    • [width=Kiwi.Stage.DEFAULT_WIDTH] Number optional

      The width of this instance of Kiwi.

    • [height=Kiwi.Stage.DEFAULT_HEIGHT] Number optional

      The height of this instance of Kiwi.

    • [scaleType=Kiwi.Stage.SCALE_NONE] Number optional

      The type of scaling that should be applied to Kiwi.

    • [plugins=[] Array optional

      A list of the names of plugins that are to be used with this game.

    • [log] Object optional

      Default state of the Log properties

      • [recording=true] Boolean optional
        If the logs should be recorded.
      • [display=true] Boolean optional
        If the logs should be displayed or not.
      • [enabled=true] Boolean optional
        If the Logger is enabled at all.
      • [maxRecordings=Infinity] Number optional
        The maximum number of recordings to have at a single time.

Returns:

Methods

_loop

() private

The game loop.

objType

() String public

The type of object that the game is.

Returns:

String:

"Game"

start

() private

The start method gets executed when the game is ready to be booted, and handles the start-up of the managers. Once the managers have started up the start loop will then begin to create the game loop.

Properties

_debugOption

Number private

If when rendering, the game should render a new CANVAS which is above everything. This new canvas is for debugging purposes only. This gets set to either DEBUG_ON or DEBUG_OFF

_delta

Number private

The current interval between frames.

_deviceTargetOption

Number private

The type of device that you are targeting. This is either set to COCOON or BROWSER

_frame

Number private

Defined in src\core\Game.ts:467

Available since 1.1.0

The number of frames since the game was launched.

_framerate

Number private

The framerate at which the game will update at.

Default: 60

_interval

Number private

The interval between frames.

Default: 1000/60

_lastTime

Number private

The last time the game was updated

_renderOption

Number private

The render mode of the game. This will be either set to CANVAS or WEBGL.

_startup

Kiwi.System.Bootstrap private

The object that peforms DOM and device startup operations for browsers (ie not cocoon)

audio

Kiwi.Sound.AudioManager public

The audio manager that handles all of the audio in game. Inside you can globally mute the audio, create new sounds, e.t.c.

bootCallbackOption

Function private

A callback function that can be passed in as an option in the conifugration object. Invoked after the boot process has completed.

cameras

Kiwi.CameraManager public

Manages the cameras the are on the stage. Single default Camera only in this version.

debug

Boolean public

Returns true if debug option is set to Kiwi.DEBUG_ON

debugOption

Number public

Returns the debug option. This is READ ONLY and is decided once the game gets initialised.

deviceTargetOption

Number public

Returns the device target option for the game. This is READ ONLY and is decided once the game gets initialised.

fileStore

Kiwi.Files.FileStore public

The global file store for this game. This handles the storage and access of information loaded, as well as tags that maybe set for them individual files.

frame

Number public

Defined in src\core\Game.ts:476

Available since 1.1.0

The number of frames since the game was launched.

Use this to drive cyclic animations. You may manually reset it in a Kiwi.State.create() function to restart the count from 0.

The largest exact integer value of a JavaScript number is 2^53, or 9007199254740992. At 60 frames per second, this will take 4,760,273 years to become inaccurate.

frameRate

Unknown public

The current frameRate that the update/render loops are running at. Note that this may not be an accurate representation.

huds

HUDManager public

Holds the hud manager.

idealFrame

Number public

Defined in src\core\Game.ts:494

Available since 1.1.0

The number of ideal frames since the game was launched.

Use this to drive cyclic animations. This will be smoother than using the frame parameter. It is derived from the total time elapsed since the game launched.

input

Kiwi.Input.InputManager public

Handles any user input with the game. These could via the users keyboard, mouse or touch events.

loader

Kiwi.Files.Loader public

Loads files from outside sources and checks to see that they have loaded correctly or not.

pluginManager

Kiwi.PluginManager public

Manages plugins registration and initialisation for the game instance.

raf

Kiwi.Utils.RequestAnimationFrame public

The Request Animation Frame that is being used for the update and render loops.

renderer

IRenderManager public

Holds the renderer that is being used. This is determined based on the _renderMode

renderOption

Number public

Returns the render mode of the game. This is READ ONLY and is decided once the game gets initialised.

rnd

Kiwi.Utils.RandomDataGenerato public

A Random Data Generator. This is useful for create unique ids and random information.

stage

Stage public

The ONLY stage that is being used for this game.

states

Kiwi.StateManager public

Manages all of the states that exist for this game. Via the manager you can create new states, switch states and do various other tasks.

time

Kiwi.Time.ClockManager public

Holds a reference to the clocks that are being used and has a MASTER clock that is being used for the game.

tweens

Kiwi.Animations.Tweens.TweenManager public

The tween manager holds a reference to all of the tweens that are created and currently being used.