mirror of
https://github.com/photonstorm/phaser
synced 2024-11-28 07:31:11 +00:00
Merge commit '0d9678e512f9037b686ca480907c90f82d5b631e' into wip-time-clarify
This commit is contained in:
commit
e2f65f58a8
4 changed files with 15 additions and 8 deletions
Binary file not shown.
Before Width: | Height: | Size: 42 KiB After Width: | Height: | Size: 44 KiB |
|
@ -293,6 +293,12 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
|
|||
*/
|
||||
this._deltaTime = 0;
|
||||
|
||||
/**
|
||||
* @property {number} count - Update iteration counter.
|
||||
* @protected
|
||||
*/
|
||||
this.count = 0;
|
||||
|
||||
/**
|
||||
* @property {number} _lastCount - remember how many 'catch-up' iterations were used on the logicUpdate last frame
|
||||
* @private
|
||||
|
@ -704,32 +710,32 @@ Phaser.Game.prototype = {
|
|||
|
||||
// call the game update logic multiple times if necessary to "catch up" with dropped frames
|
||||
// unless forceSingleUpdate is true
|
||||
var count = 0;
|
||||
this.count = 0;
|
||||
|
||||
while (this._deltaTime >= slowStep)
|
||||
{
|
||||
this._deltaTime -= slowStep;
|
||||
this.updateLogic(1.0 / this.time.desiredFps);
|
||||
count++;
|
||||
this.count++;
|
||||
|
||||
if (this.forceSingleUpdate && count === 1)
|
||||
if (this.forceSingleUpdate && this.count === 1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// detect spiralling (if the catch-up loop isn't fast enough, the number of iterations will increase constantly)
|
||||
if (count > this._lastCount)
|
||||
if (this.count > this._lastCount)
|
||||
{
|
||||
this._spiralling++;
|
||||
}
|
||||
else if (count < this._lastCount)
|
||||
else if (this.count < this._lastCount)
|
||||
{
|
||||
// looks like it caught up successfully, reset the spiral alert counter
|
||||
this._spiralling = 0;
|
||||
}
|
||||
|
||||
this._lastCount = count;
|
||||
this._lastCount = this.count;
|
||||
|
||||
// call the game render update exactly once every frame unless we're playing catch-up from a spiral condition
|
||||
this.updateRender(this._deltaTime / slowStep);
|
||||
|
|
|
@ -249,7 +249,8 @@ Phaser.Sprite.prototype.preUpdate = function() {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (this.lifespan > 0)
|
||||
// Only apply lifespan decrement in the first updateLogic pass.
|
||||
if (this.lifespan > 0 && this.game.count === 0)
|
||||
{
|
||||
this.lifespan -= 1000 * this.game.time.physicsElapsed;
|
||||
|
||||
|
|
|
@ -476,7 +476,7 @@ Phaser.Utils.Debug.prototype = {
|
|||
this.line('x: ' + sprite.x.toFixed(1) + ' y: ' + sprite.y.toFixed(1));
|
||||
this.line('angle: ' + sprite.angle.toFixed(1) + ' rotation: ' + sprite.rotation.toFixed(1));
|
||||
this.line('visible: ' + sprite.visible + ' in camera: ' + sprite.inCamera);
|
||||
this.line('bounds x: ' + sprite._bounds.x + ' y: ' + sprite._bounds.y + ' w: ' + sprite._bounds.width + ' h: ' + sprite._bounds.height);
|
||||
this.line('bounds x: ' + sprite._bounds.x.toFixed(1) + ' y: ' + sprite._bounds.y.toFixed(1) + ' w: ' + sprite._bounds.width.toFixed(1) + ' h: ' + sprite._bounds.height.toFixed(1));
|
||||
|
||||
this.stop();
|
||||
|
||||
|
|
Loading…
Reference in a new issue