Added Time.physicsElapsedMS and used in Sprite lifespan and Tweens.

This commit is contained in:
photonstorm 2014-11-26 13:13:25 +00:00
parent fb733ddcca
commit 471ad20b4a
3 changed files with 12 additions and 3 deletions

View file

@ -252,7 +252,7 @@ Phaser.Sprite.prototype.preUpdate = function() {
// Only apply lifespan decrement in the first updateLogic pass.
if (this.lifespan > 0 && this.game.updateNumber === 0)
{
this.lifespan -= this.game.time.elapsedMS;
this.lifespan -= this.game.time.physicsElapsedMS;
if (this.lifespan <= 0)
{

View file

@ -86,6 +86,13 @@ Phaser.Time = function (game) {
*/
this.physicsElapsed = 0;
/**
* The Time.physicsElapsed property * 1000.
*
* @property {number} physicsElapsedMS
*/
this.physicsElapsedMS = 0;
/**
* The desired frame rate of the game.
*
@ -355,6 +362,8 @@ Phaser.Time.prototype = {
// Set the physics elapsed time... this will always be 1 / this.desiredFps because we're using fixed time steps in game.update now
this.physicsElapsed = 1 / this.desiredFps;
this.physicsElapsedMS = this.physicsElapsed * 1000;
if (this.advancedTiming)
{
this.msMin = Math.min(this.msMin, this.elapsed);

View file

@ -332,12 +332,12 @@ Phaser.TweenData.prototype = {
if (this.parent.reverse)
{
this.dt -= (this.game.time.physicsElapsed * 1000) * this.parent.timeScale;
this.dt -= this.game.time.physicsElapsedMS * this.parent.timeScale;
this.dt = Math.max(this.dt, 0);
}
else
{
this.dt += (this.game.time.physicsElapsed * 1000) * this.parent.timeScale;
this.dt += this.game.time.physicsElapsedMS * this.parent.timeScale;
this.dt = Math.min(this.dt, this.duration);
}