Class: GameManager

GameManager()

new GameManager()

A game manager that will run any updates that you need to keep track of. Also it keeps track of levels.
Properties:
Name Type Default Description
isCollidable Boolean false value if the object can be collided with. Defaults false.
level Number 0 the current level of the game. Defaults zero.
events Array the array of events to be carried out by the game manager.
Source:

Methods

addConditionEvent(cond, func, repeat, cooldown, runFuncAtEndOfCooldownopt)

Adds a condition-based event to the game manager. Can trigger just once or repeatedly.
Parameters:
Name Type Attributes Default Description
cond function the condition to check
func function the function to run when the event is triggered
repeat Boolean whether or not to repeat the event after it occurs
cooldown Number if repeating event, cooldown can be optionally used to signify how long to wait until the event can be trigerred again
runFuncAtEndOfCooldown Boolean <optional>
false Whether or not to run the function at the end of the cooldown when an event is triggered instead of the beginning
Source:

addPostUpdateEvent(func, repeat)

Adds a event that triggers at the end of the update, before any objects are updated. Does not have any timer or condition
Parameters:
Name Type Description
func function the function to run when the event is triggered
repeat Boolean whether or not to repeat the event
Source:

addRandomCooldownConditionEvent(cond, func, repeat, cooldownStart, cooldownEnd, runFuncAtEndOfCooldownopt)

Adds a condition-based event to the game manager with a random cooldown. Can trigger just once or repeatedly, and can have cooldown between checking if triggered
Parameters:
Name Type Attributes Default Description
cond function the condition to check
func function the function to run when the event is triggered
repeat Boolean whether or not to repeat the event after it occurs
cooldownStart Number minimum value to use for cooldown
cooldownEnd Number maximum value to use for cooldown
runFuncAtEndOfCooldown Boolean <optional>
false Whether or not to run the function at the end of the cooldown when an event is triggered instead of the beginning
Source:

addRandomTimedEvent(randomStart, randomEnd, func, repeat)

Adds a randomly timed event to the game manager. Can trigger just once or repeatedly.
Parameters:
Name Type Description
randomStart Number how often to run the event at minimum
randomEnd Number how often to run the event at maximum
func function the function to call when the event occurs
repeat Boolean whether or not to repeat the event after it occurs
Source:

addTimedEvent(steps, func, repeat)

Adds a timed event to the game manager. Can trigger just once or repeatedly.
Parameters:
Name Type Description
steps Number how often to run the event
func function the function to call when the event occurs
repeat Boolean whether or not to repeat the event after it occurs
Source:

constructor()

Creates the game manager object
Source:

customUpdate(game)

Override this function to put in your custom Updates for your game. Called at start of update.
Parameters:
Name Type Description
game Game The game object
Source:

update(game)

The update function of the object. Do not override this function. Handles all events
Parameters:
Name Type Description
game Game The game object
Source: