Skip to content

Commit 6219d27

Browse files
committed
Add TimerEvent methods
- getRemaining() - getRemainingSeconds() - getOverallRemaining() - getOverallRemainingSeconds()
1 parent 0d23aea commit 6219d27

1 file changed

Lines changed: 52 additions & 0 deletions

File tree

src/time/TimerEvent.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,58 @@ var TimerEvent = new Class({
268268
return this.elapsed * 0.001;
269269
},
270270

271+
/**
272+
* Returns the time interval until the next iteration of the Timer Event.
273+
*
274+
* @method Phaser.Time.TimerEvent#getRemaining
275+
* @since 3.50.0
276+
*
277+
* @return {number} The time interval in milliseconds.
278+
*/
279+
getRemaining: function ()
280+
{
281+
return this.delay - this.elapsed;
282+
},
283+
284+
/**
285+
* Returns the time interval until the next iteration of the Timer Event in seconds.
286+
*
287+
* @method Phaser.Time.TimerEvent#getRemainingSeconds
288+
* @since 3.50.0
289+
*
290+
* @return {number} The time interval in seconds.
291+
*/
292+
getRemainingSeconds: function ()
293+
{
294+
return this.getRemaining() * 0.001;
295+
},
296+
297+
/**
298+
* Returns the time interval until the last iteration of the Timer Event.
299+
*
300+
* @method Phaser.Time.TimerEvent#getOverallRemaining
301+
* @since 3.50.0
302+
*
303+
* @return {number} The time interval in milliseconds.
304+
*/
305+
getOverallRemaining: function ()
306+
{
307+
return this.delay * (1 + this.repeatCount) - this.elapsed;
308+
},
309+
310+
/**
311+
* Returns the time interval until the last iteration of the Timer Event in seconds.
312+
*
313+
* @method Phaser.Time.TimerEvent#getOverallRemainingSeconds
314+
* @since 3.50.0
315+
*
316+
* @return {number} The time interval in seconds.
317+
*/
318+
getOverallRemainingSeconds: function ()
319+
{
320+
return this.getOverallRemaining() * 0.001;
321+
},
322+
271323
/**
272324
* Forces the Timer Event to immediately expire, thus scheduling its removal in the next frame.
273325
*

0 commit comments

Comments
 (0)