Skip to content

Commit 2219e6f

Browse files
committed
Timer.ms would report the game time ms value if the Timer hadn't yet been started, instead of 0.
Timer.seconds would report the game time value if the Timer hadn't yet been started, instead of 0.
1 parent f03445d commit 2219e6f

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,8 @@ Version 2.0.6 - "Jornhill" - -in development-
8181
* Fixed Gamepad issue that incorrectly checked non-webkit prefix gamepads.
8282
* Phaser.RenderTexture incorrectly passed the scaleMode to Pixi.RenderTexture, causing the renderer to error.
8383
* Sprite animation data wasn't reset when going from a sprite sheet to a single frame in Sprite.loadTexture (thanks @lucbloom, fix #850)
84+
* Timer.ms would report the game time ms value if the Timer hadn't yet been started, instead of 0.
85+
* Timer.seconds would report the game time value if the Timer hadn't yet been started, instead of 0.
8486

8587
### Migration Guide
8688

src/time/Timer.js

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -683,7 +683,16 @@ Object.defineProperty(Phaser.Timer.prototype, "length", {
683683
Object.defineProperty(Phaser.Timer.prototype, "ms", {
684684

685685
get: function () {
686-
return this._now - this._started - this._pauseTotal;
686+
687+
if (this.running)
688+
{
689+
return this._now - this._started - this._pauseTotal;
690+
}
691+
else
692+
{
693+
return 0;
694+
}
695+
687696
}
688697

689698
});
@@ -696,7 +705,16 @@ Object.defineProperty(Phaser.Timer.prototype, "ms", {
696705
Object.defineProperty(Phaser.Timer.prototype, "seconds", {
697706

698707
get: function () {
699-
return this.ms * 0.001;
708+
709+
if (this.running)
710+
{
711+
return this.ms * 0.001;
712+
}
713+
else
714+
{
715+
return 0;
716+
}
717+
700718
}
701719

702720
});

0 commit comments

Comments
 (0)