SpriteEventDispatcher
Type class
An EventDispatcher for Sprite.
More info: Events
Sources
This information about SpriteEventDispatcher is provided for reference only and is not available through exported packages and thus should not be imported or used on its own.
Inheritance
SpriteEventDispatcher extends EventDispatcher.
SpriteEventDispatcher is not extended by any other symbol.
Properties
SpriteEventDispatcher does not have any properties.
Methods
constructor(sprite:Sprite)Returns
SpriteEventDispatcherstopParentDispatch()Returns
voidStops the event being handled from being dispatched on the element's parents. Call it in an event handler, e.g.:
element.events.on("pointerdown", function(ev) { // Do something here and prevent from "pointerdown" bubbling up // ... ev.target.events.stopParentDispatch(); });element.events.on("pointerdown", function(ev) { // Do something here and prevent from "pointerdown" bubbling up // ... ev.target.events.stopParentDispatch(); });
17 inherited items
disable()Returns
voidInherited fromEventDispatcherDisable dispatching of events until re-enabled by
enable().disableType(type:Key,
amount:number)Returns
voidInherited fromEventDispatcherStops dispatching events of
type, untilenableType()is called or, ifamountis set, for that many dispatches.dispatch(type:Key,
event:T[""])Returns
voidInherited fromEventDispatcherCalls the listeners of
typeright away; debounced listeners are called after their delay.eventmust includetypeandtarget.dispose()Returns
voidInherited fromEventDispatcherDisposes the dispatcher and all its listeners.
enable()Returns
voidInherited fromEventDispatcherEnable dispatching of events if they were previously disabled by
disable().enableType(type:Key)Returns
voidInherited fromEventDispatcherEnable dispatching particular event, if it was disabled before by
disableType().has(type:Key,
callback?:undefined| (this:C, event:T[""]) =>void,
context?:C)Returns
booleanInherited fromEventDispatcherChecks if there's already a listener with specific parameters. Listeners added with
once()are not counted.hasListeners()Returns
booleanInherited fromEventDispatcherChecks if the dispatcher has any listeners.
hasListenersByType(type:Key)Returns
booleanInherited fromEventDispatcherChecks if the dispatcher has listeners for
type, counting the ones added withonAll().isDisposed()Returns
booleanInherited fromEventDispatcherReturns
trueif the dispatcher has been disposed.isEnabled(type:Key)Returns
booleanInherited fromEventDispatcherChecks if an event of
typewould reach a listener: events are enabled, the type is not disabled, and it has listeners.off(type:Key,
callback?:undefined| (this:C, event:T[""]) =>void,
context?:C)Returns
voidInherited fromEventDispatcherRemoves listeners added with
on()oronDebounced()that matchtype,callbackandcontext. Withoutcallback, removes all of them fortypeandcontext. Listeners added withonce()are not removed.on(type:Key,
callback: (this:C|undefined, event:T[""]) =>void,
context?:C,
shouldClone:boolean)Returns
IDisposerInherited fromEventDispatcherCreates an event listener to be invoked on a specific event type.
button.events.on("click", (ev) => { console.log("Button clicked"); }, this);button.events.on("click", function(ev) { console.log("Button clicked"); }, this);The above logs every click on the button. To remove the listener, call
dispose()on the returned object, or useoff().onAll(callback: (this:C, event:T[""]) =>void,
context?:C,
shouldClone:boolean)Returns
IDisposerInherited fromEventDispatcherCreates an event listener to be invoked on any event.
once(type:Key,
callback: (this:C|undefined, event:T[""]) =>void,
context?:C,
shouldClone:boolean)Returns
IDisposerInherited fromEventDispatcherCreates an event listener that is invoked only the first time the event happens, and is then disposed.
button.events.once("click", (ev) => { console.log("Button clicked"); }, this);button.events.once("click", function(ev) { console.log("Button clicked"); }, this);The above logs the first click on the button only.
off()does not remove such a listener: calldispose()on the returned object instead.onDebounced(type:Key,
callback: (this:C|undefined, event:T[""]) =>void,
debounceDelay:number,
context?:C,
shouldClone:boolean)Returns
IDisposerInherited fromEventDispatcherSince 5.14.0Creates a debounced event listener to be invoked on a specific event type.
button.events.onDebounced("click", (ev) => { console.log("Button clicked"); }, 500, this);button.events.onDebounced("click", function(ev) { console.log("Button clicked"); }, 500, this);The above logs once, 500 ms after the last of a series of clicks. Each new event restarts the delay, and
callbackgets the last one.More info: Events: debounced events
removeType(type:Key)Returns
voidInherited fromEventDispatcherRemoves all listeners of a particular event type.
Events
SpriteEventDispatcher does not have any events.