Navigation
These archived docs are for Phaser 2.2.2 Phaser 3 docs can be found on newdocs.phaser.io.
Phaser CE docs can be found on the Phaser CE Documentation site.

Constructor

Phaser. Events

new Events(sprite)

The Events component is a collection of events fired by the parent game object.

For example to tell when a Sprite has been added to a new group:

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

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

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/Events.js, line 23

Public Properties

onAddedToGroup : Phaser.Signal

This signal is dispatched when the parent is added to a new Group.

Source code: gameobjects/Events.js, line 72

onAnimationComplete : Phaser.Signal

This signal is dispatched when the parent has an animation that finishes playing.

Source code: gameobjects/Events.js, line 147

onAnimationLoop : Phaser.Signal

This signal is dispatched when the parent has an animation that loops playback.

Source code: gameobjects/Events.js, line 152

onAnimationStart : Phaser.Signal

This signal is dispatched when the parent has an animation that is played.

Source code: gameobjects/Events.js, line 142

onDestroy : Phaser.Signal

This signal is dispatched when the parent is destoyed.

Source code: gameobjects/Events.js, line 87

onDragStart : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives a drag start event from a Pointer.

Source code: gameobjects/Events.js, line 132

onDragStop : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives a drag stop event from a Pointer.

Source code: gameobjects/Events.js, line 137

onEnterBounds : Phaser.Signal

This signal is dispatched when the parent returns within the world bounds (only if Sprite.checkWorldBounds is true).

Source code: gameobjects/Events.js, line 107

onInputDown : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives a down event from a Pointer.

Source code: gameobjects/Events.js, line 122

onInputOut : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives an out event from a Pointer.

Source code: gameobjects/Events.js, line 117

onInputOver : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives an over event from a Pointer.

Source code: gameobjects/Events.js, line 112

onInputUp : Phaser.Signal

This signal is dispatched if the parent is inputEnabled and receives an up event from a Pointer.

Source code: gameobjects/Events.js, line 127

onKilled : Phaser.Signal

This signal is dispatched when the parent is killed.

Source code: gameobjects/Events.js, line 92

onOutOfBounds : Phaser.Signal

This signal is dispatched when the parent leaves the world bounds (only if Sprite.checkWorldBounds is true).

Source code: gameobjects/Events.js, line 102

onRemovedFromGroup : Phaser.Signal

This signal is dispatched when the parent is removed from a Group.

Source code: gameobjects/Events.js, line 77

onRemovedFromWorld : Phaser.Signal

This signal is dispatched if this item or any of its parents are removed from the game world.

Source code: gameobjects/Events.js, line 82

onRevived : Phaser.Signal

This signal is dispatched when the parent is revived.

Source code: gameobjects/Events.js, line 97

parent : Phaser.Sprite

The Sprite that owns these events.

Source code: gameobjects/Events.js, line 28

Public Methods

destroy()

Removes all events.

Source code: gameobjects/Events.js, line 36