Skip to content

Commit 471ad20

Browse files
committed
Added Time.physicsElapsedMS and used in Sprite lifespan and Tweens.
1 parent fb733dd commit 471ad20

3 files changed

Lines changed: 12 additions & 3 deletions

File tree

src/gameobjects/Sprite.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
252252
// Only apply lifespan decrement in the first updateLogic pass.
253253
if (this.lifespan > 0 && this.game.updateNumber === 0)
254254
{
255-
this.lifespan -= this.game.time.elapsedMS;
255+
this.lifespan -= this.game.time.physicsElapsedMS;
256256

257257
if (this.lifespan <= 0)
258258
{

src/time/Time.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,13 @@ Phaser.Time = function (game) {
8686
*/
8787
this.physicsElapsed = 0;
8888

89+
/**
90+
* The Time.physicsElapsed property * 1000.
91+
*
92+
* @property {number} physicsElapsedMS
93+
*/
94+
this.physicsElapsedMS = 0;
95+
8996
/**
9097
* The desired frame rate of the game.
9198
*
@@ -355,6 +362,8 @@ Phaser.Time.prototype = {
355362
// Set the physics elapsed time... this will always be 1 / this.desiredFps because we're using fixed time steps in game.update now
356363
this.physicsElapsed = 1 / this.desiredFps;
357364

365+
this.physicsElapsedMS = this.physicsElapsed * 1000;
366+
358367
if (this.advancedTiming)
359368
{
360369
this.msMin = Math.min(this.msMin, this.elapsed);

src/tween/TweenData.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -332,12 +332,12 @@ Phaser.TweenData.prototype = {
332332

333333
if (this.parent.reverse)
334334
{
335-
this.dt -= (this.game.time.physicsElapsed * 1000) * this.parent.timeScale;
335+
this.dt -= this.game.time.physicsElapsedMS * this.parent.timeScale;
336336
this.dt = Math.max(this.dt, 0);
337337
}
338338
else
339339
{
340-
this.dt += (this.game.time.physicsElapsed * 1000) * this.parent.timeScale;
340+
this.dt += this.game.time.physicsElapsedMS * this.parent.timeScale;
341341
this.dt = Math.min(this.dt, this.duration);
342342
}
343343

0 commit comments

Comments
 (0)