Events#Events

new Events(sprite)

The Events component is a collection of events fired by the parent Game Object.

Phaser uses what are known as 'Signals' for all event handling. All of the events in
this class are signals you can subscribe to, much in the same way you'd "listen" for
an event.

For example to tell when a Sprite has been added to a new group, you can bind a function
to the onAddedToGroup signal:

sprite.events.onAddedToGroup.add(yourFunction, this);

Where yourFunction is the function you want called when this event occurs.

For more details about how signals work please see the Phaser.Signal class.

The Input-related events will only be dispatched if the Sprite has had inputEnabled set to true
and the Animation-related events only apply to game objects with animations like Phaser.Sprite.

Parameters
Name Type Description
sprite Phaser.Sprite

A reference to the game object / Sprite that owns this Events object.

Source code: gameobjects/components/Events.js (Line 30)
doc_phaser
2017-02-14 10:45:42
Comments
Leave a Comment

Please login to continue.