SpriteEventDispatcher

Type class

An EventDispatcher for Sprite.

Click here for more info

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.

Settings

SpriteEventDispatcher does not have any settings.

Private settings

SpriteEventDispatcher does not have any private settings.

Properties

SpriteEventDispatcher does not have any properties.

Methods

constructor(

sprite: Sprite

)

#

Returns SpriteEventDispatcher

disable()

#

Returns void

Inherited from EventDispatcher

Disable dispatching of events until re-enabled by enable().

disableType(

type: Key,
amount: number

)

#

Returns void

Inherited from EventDispatcher

Stops dispatching events of type, until enableType() is called or, if amount is set, for that many dispatches.

dispatch(

type: Key,
event: E[""]

)

#

Returns void

Inherited from EventDispatcher

Calls the listeners of type right away; debounced listeners are called after their delay. event must include type and target.

dispose()

#

Returns void

Inherited from EventDispatcher

Disposes the dispatcher and all its listeners.

enable()

#

Returns void

Inherited from EventDispatcher

Enable dispatching of events if they were previously disabled by disable().

enableType(

type: Key

)

#

Returns void

Inherited from EventDispatcher

Enable dispatching particular event, if it was disabled before by disableType().

has(

type: Key,
callback?: undefined | ( this: C, event: E[""]) => void,
context?: C

)

#

Returns boolean

Inherited from EventDispatcher

Checks if there's already a listener with specific parameters. Listeners added with once() are not counted.

hasListeners()

#

Returns boolean

Inherited from EventDispatcher

Checks if the dispatcher has any listeners.

hasListenersByType(

type: Key

)

#

Returns boolean

Inherited from EventDispatcher

Checks if the dispatcher has listeners for type, counting the ones added with onAll().

isDisposed()

#

Returns boolean

Inherited from EventDispatcher

Returns true if the dispatcher has been disposed.

isEnabled(

type: Key

)

#

Returns boolean

Inherited from EventDispatcher

Checks if an event of type would reach a listener: events are enabled, the type is not disabled, and it has listeners.

off(

type: Key,
callback?: undefined | ( this: C, event: E[""]) => void,
context?: C

)

#

Returns void

Inherited from EventDispatcher

Removes listeners added with on() or onDebounced() that match type, callback and context. Without callback, removes all of them for type and context. Listeners added with once() are not removed.

on(

type: Key,
callback: ( this: C | undefined, event: E[""]) => void,
context?: C,
shouldClone: boolean

)

#

Returns IDisposer

Inherited from EventDispatcher

Creates 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 use off().

onAll(

callback: ( this: C, event: E[""]) => void,
context?: C,
shouldClone: boolean

)

#

Returns IDisposer

Inherited from EventDispatcher

Creates an event listener to be invoked on any event.

onDebounced(

type: Key,
callback: ( this: C | undefined, event: E[""]) => void,
debounceDelay: number,
context?: C,
shouldClone: boolean

)

#

Returns IDisposer

Inherited from EventDispatcher

Creates 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 callback gets the last one.

Click here for more info
@since 5.14.0

once(

type: Key,
callback: ( this: C | undefined, event: E[""]) => void,
context?: C,
shouldClone: boolean

)

#

Returns IDisposer

Inherited from EventDispatcher

Creates 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: call dispose() on the returned object instead.

removeType(

type: Key

)

#

Returns void

Inherited from EventDispatcher

Removes all listeners of a particular event type.

stopParentDispatch()

#

Returns void

Stops 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();
});

There are 17 inherited items currently hidden from this list.

Events

SpriteEventDispatcher does not have any events.