Skip to content

Commit 19a0638

Browse files
committed
Added Game.getFrame and Game.getTime methods.
1 parent d6bee1b commit 19a0638

1 file changed

Lines changed: 28 additions & 4 deletions

File tree

src/boot/Game.js

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,6 @@ var Game = new Class({
340340
*/
341341
this.isOver = true;
342342

343-
this.frame = 0;
344-
345343
// Wait for the DOM Ready event, then call boot.
346344
DOMContentLoaded(this.boot.bind(this));
347345
},
@@ -576,8 +574,6 @@ var Game = new Class({
576574
// The final event before the step repeats. Your last chance to do anything to the canvas before it all starts again.
577575

578576
eventEmitter.emit('postrender', renderer, time, delta);
579-
580-
this.frame++;
581577
},
582578

583579
/**
@@ -747,6 +743,34 @@ var Game = new Class({
747743
this.events.emit('resize', width, height);
748744
},
749745

746+
/**
747+
* Returns the current game frame.
748+
* When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires.
749+
*
750+
* @method Phaser.Game#getFrame
751+
* @since 3.16.0
752+
*
753+
* @return {number} The current game frame.
754+
*/
755+
getFrame: function ()
756+
{
757+
return this.loop.frame;
758+
},
759+
760+
/**
761+
* Returns the current game timestamp.
762+
* When the game starts running, the frame is incremented every time Request Animation Frame, or Set Timeout, fires.
763+
*
764+
* @method Phaser.Game#getTime
765+
* @since 3.16.0
766+
*
767+
* @return {number} The current game timestamp.
768+
*/
769+
getTime: function ()
770+
{
771+
return this.loop.frame.time;
772+
},
773+
750774
/**
751775
* Game Destroy event.
752776
*

0 commit comments

Comments
 (0)