Skip to content

Commit 3997a7c

Browse files
committed
Time.prevTime is a new property that contains the raw value of the game timer from the previous update.
Timer.timeCap has been changed from `1000` to `1 / 60 * 1000` to bring it in line with Time.timeCap.
1 parent 5d84f38 commit 3997a7c

4 files changed

Lines changed: 14 additions & 2 deletions

File tree

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,15 @@ Version 2.1.3 - "Ravinda" - in development
7676
### New Features
7777

7878
* Updated to Pixi v2.0.0
79+
* Time.prevTime is a new property that contains the raw value of the game timer from the previous update.
7980

8081
### Updates
8182

8283
* Changed the Animation constructor parameter `delay` to `frameRate` as it's a more accurate term of what it should be. Internally nothing changed.
8384
* Circle.getBounds added.
8485
* Ellipse.getBounds added.
85-
* Device.canPlayAudio now supports the `opus` files directly, as well as `opus` encoded audio stored in ogg containers (#1232)
86+
* Device.canPlayAudio now supports `opus` files directly, as well as `opus` encoded audio stored in ogg containers (#1232)
87+
* Timer.timeCap has been changed from `1000` to `1 / 60 * 1000` to bring it in line with Time.timeCap.
8688

8789
### Bug Fixes
8890

build/phaser.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5228,7 +5228,9 @@ declare module Phaser {
52285228
pausedTime: number;
52295229
pauseDuration: number;
52305230
physicsElapsed: number;
5231+
prevTime: number;
52315232
time: number;
5233+
timeCap: number;
52325234
timeToCall: number;
52335235

52345236
add(timer: Phaser.Timer): Phaser.Timer;

src/time/Time.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ Phaser.Time = function (game) {
2525
*/
2626
this.time = 0;
2727

28+
/**
29+
* @property {number} prevTime - The time the previous update occurred.
30+
* @protected
31+
*/
32+
this.prevTime = 0;
33+
2834
/**
2935
* @property {number} now - The time right now.
3036
* @protected
@@ -236,6 +242,8 @@ Phaser.Time.prototype = {
236242
*/
237243
update: function (time) {
238244

245+
this.prevTime = this.now;
246+
239247
this.now = time;
240248

241249
this.timeToCall = this.game.math.max(0, 16 - (time - this.lastTime));

src/time/Timer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ Phaser.Timer = function (game, autoDestroy) {
6767
/**
6868
* @property {number} timeCap - If the difference in time between two frame updates exceeds this value, the event times are reset to avoid catch-up situations.
6969
*/
70-
this.timeCap = 1000;
70+
this.timeCap = 1 / 60 * 1000;
7171

7272
/**
7373
* @property {boolean} paused - The paused state of the Timer. You can pause the timer by calling Timer.pause() and Timer.resume() or by the game pausing.

0 commit comments

Comments
 (0)