You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/time/Timer.js
+16-15Lines changed: 16 additions & 15 deletions
Original file line number
Diff line number
Diff line change
@@ -5,13 +5,13 @@
5
5
*/
6
6
7
7
/**
8
-
* A Timer is a way to create small re-usable (or disposable) objects that wait for a specific moment in time,
9
-
* and then run the specified callbacks.
8
+
* A Timer is a way to create and manage {@link Phaser.TimerEvent timer events} that wait for a specific duration and then run a callback.
9
+
* Many different timer events, with individual delays, can be added to the same Timer.
10
10
*
11
-
* You can add many events to a Timer, each with their own delays. A Timer uses milliseconds as its unit of time (there are 1000 ms in 1 second).
12
-
* So a delay to 250 would fire the event every quarter of a second.
11
+
* All Timer delays are in milliseconds (there are 1000 ms in 1 second); so a delay value of 250 represents a quarter of a second.
13
12
*
14
-
* Timers are based on real-world (not physics) time, adjusted for game pause durations.
13
+
* Timers are based on real life time, adjusted for game pause durations.
14
+
* That is, *timer events are based on elapsed {@link Phaser.Time game time}* and do *not* take physics time or slow motion into account.
15
15
*
16
16
* @class Phaser.Timer
17
17
* @constructor
@@ -190,10 +190,10 @@ Phaser.Timer.prototype = {
190
190
*
191
191
* @method Phaser.Timer#create
192
192
* @private
193
-
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback. This value should be an integer, not a float. Math.round() is applied to it by this method.
193
+
* @param {integer} delay - The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs.
194
194
* @param {boolean} loop - Should the event loop or not?
195
195
* @param {number} repeatCount - The number of times the event will repeat.
196
-
* @param {function} callback - The callback that will be called when the Timer event occurs.
196
+
* @param {function} callback - The callback that will be called when the timer event occurs.
197
197
* @param {object} callbackContext - The context in which the callback will be called.
198
198
* @param {any[]} arguments - The values to be sent to your callback function when it is called.
199
199
* @return {Phaser.TimerEvent} The Phaser.TimerEvent object that was created.
@@ -234,8 +234,8 @@ Phaser.Timer.prototype = {
234
234
* Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer.
235
235
*
236
236
* @method Phaser.Timer#add
237
-
* @param {number} delay - The number of milliseconds that should elapse before the callback is invoked.
238
-
* @param {function} callback - The callback that will be called when the Timer event occurs.
237
+
* @param {integer} delay - The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs.
238
+
* @param {function} callback - The callback that will be called when the timer event occurs.
239
239
* @param {object} callbackContext - The context in which the callback will be called.
240
240
* @param {...*} arguments - Additional arguments that will be supplied to the callback.
241
241
* @return {Phaser.TimerEvent} The Phaser.TimerEvent object that was created.
@@ -250,14 +250,15 @@ Phaser.Timer.prototype = {
250
250
* Adds a new TimerEvent that will always play through once and then repeat for the given number of iterations.
251
251
*
252
252
* The event will fire after the given amount of `delay` in milliseconds has passed, once the Timer has started running.
253
-
* The delay is in relation to when the Timer starts, not the time it was added. If the Timer is already running the delay will be calculated based on the timers current time.
253
+
* The delay is in relation to when the Timer starts, not the time it was added.
254
+
* If the Timer is already running the delay will be calculated based on the timers current time.
254
255
*
255
256
* Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer.
256
257
*
257
258
* @method Phaser.Timer#repeat
258
-
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
259
+
* @param {integer} delay - The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs.
259
260
* @param {number} repeatCount - The number of times the event will repeat once is has finished playback. A repeatCount of 1 means it will repeat itself once, playing the event twice in total.
260
-
* @param {function} callback - The callback that will be called when the Timer event occurs.
261
+
* @param {function} callback - The callback that will be called when the timer event occurs.
261
262
* @param {object} callbackContext - The context in which the callback will be called.
262
263
* @param {...*} arguments - Additional arguments that will be supplied to the callback.
263
264
* @return {Phaser.TimerEvent} The Phaser.TimerEvent object that was created.
@@ -277,8 +278,8 @@ Phaser.Timer.prototype = {
277
278
* Make sure to call {@link Phaser.Timer#start start} after adding all of the Events you require for this Timer.
278
279
*
279
280
* @method Phaser.Timer#loop
280
-
* @param {number} delay - The number of milliseconds that should elapse before the Timer will call the given callback.
281
-
* @param {function} callback - The callback that will be called when the Timer event occurs.
281
+
* @param {integer} delay - The number of milliseconds, in {@link Phaser.Time game time}, before the timer event occurs.
282
+
* @param {function} callback - The callback that will be called when the timer event occurs.
282
283
* @param {object} callbackContext - The context in which the callback will be called.
283
284
* @param {...*} arguments - Additional arguments that will be supplied to the callback.
284
285
* @return {Phaser.TimerEvent} The Phaser.TimerEvent object that was created.
@@ -292,7 +293,7 @@ Phaser.Timer.prototype = {
292
293
/**
293
294
* Starts this Timer running.
294
295
* @method Phaser.Timer#start
295
-
* @param {number} [delay=0] - The number of milliseconds that should elapse before the Timer will start.
296
+
* @param {integer} [delay=0] - The number of milliseconds, in {@link Phaser.Time game time}, that should elapse before the Timer will start.
0 commit comments