mirror of
https://github.com/photonstorm/phaser
synced 2025-02-17 14:38:30 +00:00
Added jsdocs
This commit is contained in:
parent
36229eee79
commit
d9227420b3
1 changed files with 154 additions and 3 deletions
|
@ -2,15 +2,38 @@ var Class = require('../utils/Class');
|
|||
var PluginManager = require('../plugins/PluginManager');
|
||||
var TimerEvent = require('./TimerEvent');
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @class Clock
|
||||
* @memberOf Phaser.Time
|
||||
* @constructor
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {Phaser.Scene} scene - [description]
|
||||
*/
|
||||
var Clock = new Class({
|
||||
|
||||
initialize:
|
||||
|
||||
function Clock (scene)
|
||||
{
|
||||
// The Scene that owns this plugin
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#scene
|
||||
* @type {Phaser.Scene}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.scene = scene;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#systems
|
||||
* @type {Phaser.Scenes.Systems}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.systems = scene.sys;
|
||||
|
||||
if (!scene.sys.settings.isBooted)
|
||||
|
@ -18,19 +41,78 @@ var Clock = new Class({
|
|||
scene.sys.events.once('boot', this.boot, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#now
|
||||
* @type {number}
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.now = Date.now();
|
||||
|
||||
// Scale the delta time coming into the Clock by this factor
|
||||
// which then influences anything using this Clock for calculations, like TimerEvents
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#timeScale
|
||||
* @type {float}
|
||||
* @default 1
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.timeScale = 1;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#paused
|
||||
* @type {boolean}
|
||||
* @default false
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this.paused = false;
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#_active
|
||||
* @type {Phaser.Time.TimerEvent[]}
|
||||
* @private
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._active = [];
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#_pendingInsertion
|
||||
* @type {Phaser.Time.TimerEvent[]}
|
||||
* @private
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._pendingInsertion = [];
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @name Phaser.Time.Clock#_pendingRemoval
|
||||
* @type {Phaser.Time.TimerEvent[]}
|
||||
* @private
|
||||
* @default []
|
||||
* @since 3.0.0
|
||||
*/
|
||||
this._pendingRemoval = [];
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#boot
|
||||
* @since 3.0.0
|
||||
*/
|
||||
boot: function ()
|
||||
{
|
||||
var eventEmitter = this.systems.events;
|
||||
|
@ -41,6 +123,16 @@ var Clock = new Class({
|
|||
eventEmitter.on('destroy', this.destroy, this);
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#addEvent
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {object} config - [description]
|
||||
*
|
||||
* @return {Phaser.Time.TimerEvent} [description]
|
||||
*/
|
||||
addEvent: function (config)
|
||||
{
|
||||
var event = new TimerEvent(config);
|
||||
|
@ -50,16 +142,47 @@ var Clock = new Class({
|
|||
return event;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#delayedCall
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} delay - [description]
|
||||
* @param {function} callback - [description]
|
||||
* @param {array} args - [description]
|
||||
* @param {object} callbackScope - [description]
|
||||
*
|
||||
* @return {[type]} [description]
|
||||
*/
|
||||
delayedCall: function (delay, callback, args, callbackScope)
|
||||
{
|
||||
return this.addEvent({ delay: delay, callback: callback, args: args, callbackScope: callbackScope });
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#clearPendingEvents
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Time.Clock} [description]
|
||||
*/
|
||||
clearPendingEvents: function ()
|
||||
{
|
||||
this._pendingInsertion = [];
|
||||
|
||||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#removeAllEvents
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @return {Phaser.Time.Clock} [description]
|
||||
*/
|
||||
removeAllEvents: function ()
|
||||
{
|
||||
this._pendingRemoval = this._pendingRemoval.concat(this._active);
|
||||
|
@ -67,6 +190,15 @@ var Clock = new Class({
|
|||
return this;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#preUpdate
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
*/
|
||||
preUpdate: function (time, delta)
|
||||
{
|
||||
var toRemove = this._pendingRemoval.length;
|
||||
|
@ -109,6 +241,15 @@ var Clock = new Class({
|
|||
this._pendingInsertion.length = 0;
|
||||
},
|
||||
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#update
|
||||
* @since 3.0.0
|
||||
*
|
||||
* @param {number} time - [description]
|
||||
* @param {number} delta - [description]
|
||||
*/
|
||||
update: function (time, delta)
|
||||
{
|
||||
this.now = time;
|
||||
|
@ -164,7 +305,12 @@ var Clock = new Class({
|
|||
}
|
||||
},
|
||||
|
||||
// Scene that owns this Clock is shutting down
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#shutdown
|
||||
* @since 3.0.0
|
||||
*/
|
||||
shutdown: function ()
|
||||
{
|
||||
var i;
|
||||
|
@ -189,7 +335,12 @@ var Clock = new Class({
|
|||
this._pendingInsertion.length = 0;
|
||||
},
|
||||
|
||||
// Game level nuke
|
||||
/**
|
||||
* [description]
|
||||
*
|
||||
* @method Phaser.Time.Clock#destroy
|
||||
* @since 3.0.0
|
||||
*/
|
||||
destroy: function ()
|
||||
{
|
||||
this.shutdown();
|
||||
|
|
Loading…
Add table
Reference in a new issue