zerk.game.engine Class
The game engine main class
Item Index
Methods
Properties
Events
Methods
_log
(
protected
-
msg
Local log method
Parameters:
-
msg
String
_tick
()
protected
Game engine tick
fireEvent
(
Boolen
-
event
Fire event
Parameters:
-
event
StringEvent name
Returns:
Boolen:
Returns false when the bubble was canceled
getTime
()
Integer
Returns current world time
Returns:
Integer:
World time
init
(
-
config
Class constructor
Parameters:
-
config
ObjectGame 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
StringClass name of the world to be loaded
on
(
-
event
-
callback
-
scope
Register event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback function. Return false to cancel event bubble.
-
scope
ObjectScope 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
(
Boolen
-
event
-
callback
Unregister event handler
Parameters:
-
event
StringEvent name
-
callback
FunctionCallback 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
Events
tick
Fires every world simulation tick
worldunloaded
Fires after the world is unloaded