new b5.EventsManager(){b5.EventManager}
core/events.js, line 37
An events manager can be attached to an object and used to handle named user event subscription and notification.
Example showing how to subscribe and raise events:
var app = b5.app;
app.events.on("Hello", function(event)
{
console.log("Hello event was raised by app");
console.log(event);
}, this);
app.events.dispatch("Hello");
var scene = b5.Utils.findObjectFromPath("gamescene");
scene.events.on("Hello", function(event)
{
console.log("Hello event was raised by scene");
console.log(event);
}, this);
scene.events.dispatch("Hello");
Properties:
Name | Type | Description |
---|---|---|
events |
Array.<object> | Evenst list |
Returns:
Type | Description |
---|---|
b5.EventManager | The created events manager |
Methods
-
clear()
core/events.js, line 71 -
Removes all events from the manager
-
dispatch(event_name)
core/events.js, line 80 -
Dispatches the specified event calling the attached functions
Name Type Description event_name
string Name of event to dispatch
-
on(event_name, event_function, event_data)
core/events.js, line 49 -
Add the specified named event and function pair to the events manager
Name Type Description event_name
string Name of event to listen to
event_function
function Function to call when this event is raised
event_data
object Data to pass to the function
-
remove(event_name)
core/events.js, line 58 -
Removes the specified event from the events manager
Name Type Description event_name
string Name of event to remove