Creates a new event manager.
Optional
config: EventManagerConfigThe config to use for this event manager.
Optional
events: readonly Events[]The events to add to the event manager. These events will be added to the event manager's callback events, although you could omit this and add events manually (though this is not recommended as you won't get type checking).
Adds a new event. Alias for EventManager.setEvent. Only here for backwards compatibility.
Adds a new event or changes an existing event to the event system. If you want to add a callback event, use EventManager.on instead.
The name of the event. If an event with this name already exists, it will be overwritten.
The type of the event, either "interval" or "timeout".
The delay in milliseconds before the event triggers. (NOTE: If delay is less than the framerate, it will at trigger at max, once every frame.)
The callback function to execute when the event triggers.
const myEventManger = new eventManager();
// Add an interval event that executes every 2 seconds.
myEventManger.addEvent("IntervalEvent", "interval", 2000, () => {
console.log("Interval event executed.");
});
// Add a timeout event that executes after 5 seconds.
myEventManger.addEvent("TimeoutEvent", "timeout", 5000, () => {
console.log("Timeout event executed.");
});
Use EventManager.setEvent instead.
Readonly
configThe config object
Dispatches / calls all callbacks for an event added with EventManager.on.
The event to dispatch.
Adds a callback to an event. If you want to use a timer event, use EventManager.setEvent instead.
The event to add the callback to.
The callback to add to the event.
Adds a new event or changes an existing event to the event system. If you want to add a callback event, use EventManager.on instead.
The name of the event. If an event with this name already exists, it will be overwritten.
The type of the event, either "interval" or "timeout".
The delay in milliseconds before the event triggers. (NOTE: If delay is less than the framerate, it will at trigger at max, once every frame.)
The callback function to execute when the event triggers.
const myEventManger = new eventManager();
// Add an interval event that executes every 2 seconds.
myEventManger.addEvent("IntervalEvent", "interval", 2000, () => {
console.log("Interval event executed.");
});
// Add a timeout event that executes after 5 seconds.
myEventManger.addEvent("TimeoutEvent", "timeout", 5000, () => {
console.log("Timeout event executed.");
});
The event manager class, used to manage events and execute them at the correct time.