@@ -2,35 +2,117 @@ var Class = require('../utils/Class');
22var PluginManager = require ( '../plugins/PluginManager' ) ;
33var TimerEvent = require ( './TimerEvent' ) ;
44
5+ /**
6+ * [description]
7+ *
8+ * @class Clock
9+ * @memberOf Phaser.Time
10+ * @constructor
11+ * @since 3.0.0
12+ *
13+ * @param {Phaser.Scene } scene - [description]
14+ */
515var Clock = new Class ( {
616
717 initialize :
818
919 function Clock ( scene )
1020 {
11- // The Scene that owns this plugin
21+ /**
22+ * [description]
23+ *
24+ * @name Phaser.Time.Clock#scene
25+ * @type {Phaser.Scene }
26+ * @since 3.0.0
27+ */
1228 this . scene = scene ;
1329
30+ /**
31+ * [description]
32+ *
33+ * @name Phaser.Time.Clock#systems
34+ * @type {Phaser.Scenes.Systems }
35+ * @since 3.0.0
36+ */
1437 this . systems = scene . sys ;
1538
1639 if ( ! scene . sys . settings . isBooted )
1740 {
1841 scene . sys . events . once ( 'boot' , this . boot , this ) ;
1942 }
2043
44+ /**
45+ * [description]
46+ *
47+ * @name Phaser.Time.Clock#now
48+ * @type {number }
49+ * @since 3.0.0
50+ */
2151 this . now = Date . now ( ) ;
2252
2353 // Scale the delta time coming into the Clock by this factor
2454 // which then influences anything using this Clock for calculations, like TimerEvents
55+
56+ /**
57+ * [description]
58+ *
59+ * @name Phaser.Time.Clock#timeScale
60+ * @type {float }
61+ * @default 1
62+ * @since 3.0.0
63+ */
2564 this . timeScale = 1 ;
2665
66+ /**
67+ * [description]
68+ *
69+ * @name Phaser.Time.Clock#paused
70+ * @type {boolean }
71+ * @default false
72+ * @since 3.0.0
73+ */
2774 this . paused = false ;
2875
76+ /**
77+ * [description]
78+ *
79+ * @name Phaser.Time.Clock#_active
80+ * @type {Phaser.Time.TimerEvent[] }
81+ * @private
82+ * @default []
83+ * @since 3.0.0
84+ */
2985 this . _active = [ ] ;
86+
87+ /**
88+ * [description]
89+ *
90+ * @name Phaser.Time.Clock#_pendingInsertion
91+ * @type {Phaser.Time.TimerEvent[] }
92+ * @private
93+ * @default []
94+ * @since 3.0.0
95+ */
3096 this . _pendingInsertion = [ ] ;
97+
98+ /**
99+ * [description]
100+ *
101+ * @name Phaser.Time.Clock#_pendingRemoval
102+ * @type {Phaser.Time.TimerEvent[] }
103+ * @private
104+ * @default []
105+ * @since 3.0.0
106+ */
31107 this . _pendingRemoval = [ ] ;
32108 } ,
33109
110+ /**
111+ * [description]
112+ *
113+ * @method Phaser.Time.Clock#boot
114+ * @since 3.0.0
115+ */
34116 boot : function ( )
35117 {
36118 var eventEmitter = this . systems . events ;
@@ -41,6 +123,16 @@ var Clock = new Class({
41123 eventEmitter . on ( 'destroy' , this . destroy , this ) ;
42124 } ,
43125
126+ /**
127+ * [description]
128+ *
129+ * @method Phaser.Time.Clock#addEvent
130+ * @since 3.0.0
131+ *
132+ * @param {object } config - [description]
133+ *
134+ * @return {Phaser.Time.TimerEvent } [description]
135+ */
44136 addEvent : function ( config )
45137 {
46138 var event = new TimerEvent ( config ) ;
@@ -50,23 +142,63 @@ var Clock = new Class({
50142 return event ;
51143 } ,
52144
145+ /**
146+ * [description]
147+ *
148+ * @method Phaser.Time.Clock#delayedCall
149+ * @since 3.0.0
150+ *
151+ * @param {number } delay - [description]
152+ * @param {function } callback - [description]
153+ * @param {array } args - [description]
154+ * @param {object } callbackScope - [description]
155+ *
156+ * @return {[type] } [description]
157+ */
53158 delayedCall : function ( delay , callback , args , callbackScope )
54159 {
55160 return this . addEvent ( { delay : delay , callback : callback , args : args , callbackScope : callbackScope } ) ;
56161 } ,
57162
163+ /**
164+ * [description]
165+ *
166+ * @method Phaser.Time.Clock#clearPendingEvents
167+ * @since 3.0.0
168+ *
169+ * @return {Phaser.Time.Clock } [description]
170+ */
58171 clearPendingEvents : function ( )
59172 {
60173 this . _pendingInsertion = [ ] ;
174+
175+ return this ;
61176 } ,
62177
178+ /**
179+ * [description]
180+ *
181+ * @method Phaser.Time.Clock#removeAllEvents
182+ * @since 3.0.0
183+ *
184+ * @return {Phaser.Time.Clock } [description]
185+ */
63186 removeAllEvents : function ( )
64187 {
65188 this . _pendingRemoval = this . _pendingRemoval . concat ( this . _active ) ;
66189
67190 return this ;
68191 } ,
69192
193+ /**
194+ * [description]
195+ *
196+ * @method Phaser.Time.Clock#preUpdate
197+ * @since 3.0.0
198+ *
199+ * @param {number } time - [description]
200+ * @param {number } delta - [description]
201+ */
70202 preUpdate : function ( time , delta )
71203 {
72204 var toRemove = this . _pendingRemoval . length ;
@@ -109,6 +241,15 @@ var Clock = new Class({
109241 this . _pendingInsertion . length = 0 ;
110242 } ,
111243
244+ /**
245+ * [description]
246+ *
247+ * @method Phaser.Time.Clock#update
248+ * @since 3.0.0
249+ *
250+ * @param {number } time - [description]
251+ * @param {number } delta - [description]
252+ */
112253 update : function ( time , delta )
113254 {
114255 this . now = time ;
@@ -164,7 +305,12 @@ var Clock = new Class({
164305 }
165306 } ,
166307
167- // Scene that owns this Clock is shutting down
308+ /**
309+ * [description]
310+ *
311+ * @method Phaser.Time.Clock#shutdown
312+ * @since 3.0.0
313+ */
168314 shutdown : function ( )
169315 {
170316 var i ;
@@ -189,7 +335,12 @@ var Clock = new Class({
189335 this . _pendingInsertion . length = 0 ;
190336 } ,
191337
192- // Game level nuke
338+ /**
339+ * [description]
340+ *
341+ * @method Phaser.Time.Clock#destroy
342+ * @since 3.0.0
343+ */
193344 destroy : function ( )
194345 {
195346 this . shutdown ( ) ;
0 commit comments