2014-01-09 00:59:37 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2014-02-05 05:54:25 +00:00
|
|
|
* @copyright 2014 Photon Storm Ltd.
|
2014-01-09 00:59:37 +00:00
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2014-09-16 18:44:04 +00:00
|
|
|
* A TimerEvent is a single event that is processed by a Phaser.Timer.
|
2014-11-26 23:16:01 +00:00
|
|
|
*
|
2014-09-16 18:44:04 +00:00
|
|
|
* It consists of a delay, which is a value in milliseconds after which the event will fire.
|
2014-11-26 23:16:01 +00:00
|
|
|
* When the event fires it calls a specific callback with the specified arguments.
|
|
|
|
*
|
|
|
|
* Use {@link Phaser.Timer#add}, {@link Phaser.Timer#add}, or {@link Phaser.Timer#add} methods to create a new event.
|
2014-01-09 00:59:37 +00:00
|
|
|
*
|
|
|
|
* @class Phaser.TimerEvent
|
|
|
|
* @constructor
|
|
|
|
* @param {Phaser.Timer} timer - The Timer object that this TimerEvent belongs to.
|
|
|
|
* @param {number} delay - The delay in ms at which this TimerEvent fires.
|
|
|
|
* @param {number} tick - The tick is the next game clock time that this event will fire at.
|
|
|
|
* @param {number} repeatCount - If this TimerEvent repeats it will do so this many times.
|
|
|
|
* @param {boolean} loop - True if this TimerEvent loops, otherwise false.
|
|
|
|
* @param {function} callback - The callback that will be called when the TimerEvent occurs.
|
|
|
|
* @param {object} callbackContext - The context in which the callback will be called.
|
2014-11-26 23:16:01 +00:00
|
|
|
* @param {array} arguments - Additional arguments to be passed to the callback.
|
2014-01-09 00:59:37 +00:00
|
|
|
*/
|
|
|
|
Phaser.TimerEvent = function (timer, delay, tick, repeatCount, loop, callback, callbackContext, args) {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {Phaser.Timer} timer - The Timer object that this TimerEvent belongs to.
|
2014-11-26 23:16:01 +00:00
|
|
|
* @protected
|
|
|
|
* @readonly
|
2014-01-09 00:59:37 +00:00
|
|
|
*/
|
|
|
|
this.timer = timer;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {number} delay - The delay in ms at which this TimerEvent fires.
|
|
|
|
*/
|
|
|
|
this.delay = delay;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {number} tick - The tick is the next game clock time that this event will fire at.
|
|
|
|
*/
|
|
|
|
this.tick = tick;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {number} repeatCount - If this TimerEvent repeats it will do so this many times.
|
|
|
|
*/
|
|
|
|
this.repeatCount = repeatCount - 1;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {boolean} loop - True if this TimerEvent loops, otherwise false.
|
|
|
|
*/
|
|
|
|
this.loop = loop;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {function} callback - The callback that will be called when the TimerEvent occurs.
|
|
|
|
*/
|
|
|
|
this.callback = callback;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @property {object} callbackContext - The context in which the callback will be called.
|
|
|
|
*/
|
|
|
|
this.callbackContext = callbackContext;
|
|
|
|
|
|
|
|
/**
|
2014-11-26 23:16:01 +00:00
|
|
|
* @property {any[]} arguments - Additional arguments to be passed to the callback.
|
2014-01-09 00:59:37 +00:00
|
|
|
*/
|
|
|
|
this.args = args;
|
|
|
|
|
2014-02-05 22:35:35 +00:00
|
|
|
/**
|
|
|
|
* @property {boolean} pendingDelete - A flag that controls if the TimerEvent is pending deletion.
|
|
|
|
* @protected
|
|
|
|
*/
|
|
|
|
this.pendingDelete = false;
|
|
|
|
|
2014-01-09 00:59:37 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
Phaser.TimerEvent.prototype.constructor = Phaser.TimerEvent;
|