2013-10-01 12:54:29 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2014-02-05 05:54:25 +00:00
|
|
|
* @copyright 2014 Photon Storm Ltd.
|
2013-10-01 12:54:29 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
2013-09-08 21:38:19 +00:00
|
|
|
/**
|
2013-10-01 12:54:29 +00:00
|
|
|
* @class Phaser.Events
|
2013-11-28 15:57:09 +00:00
|
|
|
*
|
|
|
|
* @classdesc 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:
|
|
|
|
*
|
2014-03-03 16:05:55 +00:00
|
|
|
* `sprite.events.onAddedToGroup.add(yourFunction, this);`
|
2013-11-28 15:57:09 +00:00
|
|
|
*
|
|
|
|
* Where `yourFunction` is the function you want called when this event occurs.
|
|
|
|
*
|
|
|
|
* Note that the Input related events only exist if the Sprite has had `inputEnabled` set to `true`.
|
|
|
|
*
|
2013-10-01 12:54:29 +00:00
|
|
|
* @constructor
|
|
|
|
*
|
|
|
|
* @param {Phaser.Sprite} sprite - A reference to Description.
|
2013-09-08 21:38:19 +00:00
|
|
|
*/
|
|
|
|
Phaser.Events = function (sprite) {
|
2013-11-25 03:13:04 +00:00
|
|
|
|
|
|
|
this.parent = sprite;
|
2014-02-05 02:39:03 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
this.onAddedToGroup = new Phaser.Signal();
|
|
|
|
this.onRemovedFromGroup = new Phaser.Signal();
|
|
|
|
this.onKilled = new Phaser.Signal();
|
|
|
|
this.onRevived = new Phaser.Signal();
|
|
|
|
this.onOutOfBounds = new Phaser.Signal();
|
2013-09-08 21:38:19 +00:00
|
|
|
|
|
|
|
this.onInputOver = null;
|
|
|
|
this.onInputOut = null;
|
|
|
|
this.onInputDown = null;
|
|
|
|
this.onInputUp = null;
|
|
|
|
this.onDragStart = null;
|
|
|
|
this.onDragStop = null;
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
this.onAnimationStart = null;
|
|
|
|
this.onAnimationComplete = null;
|
|
|
|
this.onAnimationLoop = null;
|
2013-09-10 19:40:34 +00:00
|
|
|
|
2013-10-13 00:29:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Phaser.Events.prototype = {
|
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
destroy: function () {
|
2013-10-13 00:29:57 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
this.parent = null;
|
|
|
|
this.onAddedToGroup.dispose();
|
|
|
|
this.onRemovedFromGroup.dispose();
|
|
|
|
this.onKilled.dispose();
|
|
|
|
this.onRevived.dispose();
|
|
|
|
this.onOutOfBounds.dispose();
|
2013-10-13 00:29:57 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.onInputOver)
|
|
|
|
{
|
|
|
|
this.onInputOver.dispose();
|
|
|
|
this.onInputOut.dispose();
|
|
|
|
this.onInputDown.dispose();
|
|
|
|
this.onInputUp.dispose();
|
|
|
|
this.onDragStart.dispose();
|
|
|
|
this.onDragStop.dispose();
|
|
|
|
}
|
2013-10-13 00:29:57 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
if (this.onAnimationStart)
|
|
|
|
{
|
|
|
|
this.onAnimationStart.dispose();
|
|
|
|
this.onAnimationComplete.dispose();
|
|
|
|
this.onAnimationLoop.dispose();
|
|
|
|
}
|
2013-10-13 00:29:57 +00:00
|
|
|
|
2013-11-25 03:13:04 +00:00
|
|
|
}
|
2013-10-13 00:29:57 +00:00
|
|
|
|
2013-12-30 16:54:00 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Phaser.Events.prototype.constructor = Phaser.Events;
|