API Docs for: 0.1.0
Show:

zerk.game.engine Class

The game engine main class

Methods

_log

(
  • msg
)
protected

Local log method

Parameters:

  • msg String

_tick

() protected

Game engine tick

fireEvent

(
  • event
)
Boolen

Fire event

Parameters:

  • event String

    Event name

Returns:

Boolen: Returns false when the bubble was canceled

getTime

() Integer

Returns current world time

Returns:

Integer: World time

init

(
  • config
)

Inherited from zerk.observable but overwritten in src/zerk/class/game/engine.js:152

Class constructor

Parameters:

  • config Object

    Game configuration

isRunning

() Boolean

Returns true if the game engine is running

Returns:

Boolean: True if the game engine is running

loadWorld

(
  • worldClass
)

Loads a world

Parameters:

  • worldClass String

    Class name of the world to be loaded

on

(
  • event
  • callback
  • scope
)

Register event handler

Parameters:

  • event String

    Event name

  • callback Function

    Callback function. Return false to cancel event bubble.

  • scope Object

    Scope to be used in callback function

pause

()

Pause game engine

saveWorld

() String

Save world state

Returns:

String: World state as JSON string

start

()

Start game engine

stop

()

Stop game engine

un

(
  • event
  • callback
)
Boolen

Unregister event handler

Parameters:

  • event String

    Event name

  • callback Function

    Callback function

Returns:

Boolen: Returns true on success

unloadWorld

()

Unloads the world

Properties

_config

Null | Object protected

Engine configuration

_eventListeners

Array protected

List of event handlers

_running

Boolean protected

Indicates that the engine is running

_time

Integer protected

Total world runtime

_timer

Null | Timer protected

World timer

_unloadingWorld

Boolean protected

Indicates that the world is unloading

_worldInterval

Integer protected

World timer interval

control

zerk.game.engine.control

Human input controls

game

zerk.game

Back reference to the game class

physics

zerk.game.engine.physics

Physics simulation

registry

zerk.game.engine.registry

Game engine registry

viewport

zerk.game.engine.viewport

Grafical presentation

Events

tick

Fires every world simulation tick

worldunloaded

Fires after the world is unloaded