Skip to content

Commit 813429d

Browse files
committed
Added getDuration and getDurationMS
1 parent 95eb4fc commit 813429d

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

src/core/TimeStep.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,32 @@ var TimeStep = new Class({
609609
this.step(window.performance.now());
610610
},
611611

612+
/**
613+
* Gets the duration which the game has been running, in seconds.
614+
*
615+
* @method Phaser.Core.TimeStep#getDuration
616+
* @since 3.17.0
617+
*
618+
* @return {number} The duration in seconds.
619+
*/
620+
getDuration: function ()
621+
{
622+
return Math.round(this.lastTime - this.startTime) / 1000;
623+
},
624+
625+
/**
626+
* Gets the duration which the game has been running, in ms.
627+
*
628+
* @method Phaser.Core.TimeStep#getDurationMS
629+
* @since 3.17.0
630+
*
631+
* @return {number} The duration in ms.
632+
*/
633+
getDurationMS: function ()
634+
{
635+
return Math.round(this.lastTime - this.startTime);
636+
},
637+
612638
/**
613639
* Stops the TimeStep running.
614640
*

0 commit comments

Comments
 (0)