EventDispatcher

EventDispatcher

This class manages all events by a game manager. When adding a handler to an event with another handler,the latter will not be overriden,rather,the former will be added to complement the latter.

Constructor

new EventDispatcher()

Source:

Methods

add(name, handler)

Description:
  • Adds an event handler to an event dispatcher.
Source:
Parameters:
Name Type Description
name string name of the event.
handler EventHandlerFunc Function to be called when the event is triggered.

addEvent(n, data)

Source:
Parameters:
Name Type Description
n string
data any

getEvent(n)

Source:
Parameters:
Name Type Description
n string

trigger(n, data)

Description:
  • This fires all event handlers of a certain event.
Source:
Parameters:
Name Type Description
n string the name of event fired.
data any The payload of the event.