Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
Removes all listeners from this EventEmitter and prepares it for garbage collection. This method is called automatically when the parent object is destroyed and should not be called directly unless you are tearing down the emitter manually.
Calls each of the listeners registered for a given event.
The event name.
Additional arguments that will be passed to the event handler.
true if the event had listeners, else false.
Return an array listing the events for which the emitter has registered listeners.undefined
undefined
Return the number of listeners listening to a given event.
The event name.
The number of listeners.
Return the listeners registered for a given event.
The event name.
The registered listeners.
Remove the listeners of a given event.
The event name.
Optionalfn: Function
Only remove the listeners that match this function.
Optionalcontext: any
Only remove the listeners that have this context.
Optionalonce: boolean
Only remove one-time listeners.
this.
Add a listener for a given event.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
Add a one-time listener for a given event. The listener is automatically removed the first time the event is emitted, so it will never be called more than once.
The event name.
The listener function.
Optionalcontext: any
The context to invoke the listener with. Default this.
this.
Remove all listeners, or those of the specified event.
Optionalevent: string | symbol
The event name.
this.
Remove the listeners of a given event.
The event name.
Optionalfn: Function
Only remove the listeners that match this function.
Optionalcontext: any
Only remove the listeners that have this context.
Optionalonce: boolean
Only remove one-time listeners.
this.
Removes all listeners from this EventEmitter. This method is called automatically by the Scene Systems when the parent Scene shuts down, ensuring that all event bindings are cleared and no stale references remain.
EventEmitter is a Scene Systems plugin compatible wrapper around the
eventemitter3library, providing a full-featured event emitter used throughout Phaser for event-driven communication between game objects, scenes, and systems.Every Scene has an instance of this class available via
scene.events, and many Phaser objects extend or embed it to dispatch and receive events. It supports persistent listeners viaon/addListener, one-time listeners that auto-remove after firing viaonce, and listener removal viaoff/removeListener.You can also instantiate it directly when you need a standalone event bus within your own code.