Added Game core loop stepping support. Super-useful for debugging, and helped me track down the issue with jittery physics collision. Double-win!

This commit is contained in:
photonstorm
2014-01-29 17:10:13 +00:00
parent d51a37211c
commit 651858372c
25 changed files with 1268 additions and 438 deletions
+44 -13
View File
@@ -283,6 +283,10 @@ Phaser.Game = function (width, height, renderer, parent, state, transparent, ant
window.addEventListener('load', this._onBoot, false);
}
this.pendingStep = false;
this.stepping = true;
this.stepCount = 0;
return this;
};
@@ -580,20 +584,32 @@ Phaser.Game.prototype = {
}
else
{
this.plugins.preUpdate();
this.world.preUpdate();
if (!this.pendingStep)
{
if (this.stepping)
{
this.pendingStep = true;
}
this.stage.update();
this.input.update();
this.tweens.update();
this.sound.update();
this.state.update();
this.world.update();
this.particles.update();
this.plugins.update();
this.plugins.preUpdate();
console.log('world preUpdate');
this.world.preUpdate();
this.world.postUpdate();
this.plugins.postUpdate();
this.stage.update();
this.input.update();
this.tweens.update();
this.sound.update();
console.log('state update');
this.state.update();
console.log('world update');
this.world.update();
this.particles.update();
this.plugins.update();
console.log('world postUpdate');
this.world.postUpdate();
this.plugins.postUpdate();
}
if (this.renderType !== Phaser.HEADLESS)
{
@@ -603,11 +619,26 @@ Phaser.Game.prototype = {
this.plugins.postRender();
}
}
},
enableStep: function () {
this.stepping = true;
this.pendingStep = false;
this.stepCount = 0;
},
step: function () {
this.pendingStep = false;
this.stepCount++;
console.log('--------- Game step', this.stepCount);
},
/**
* Nuke the entire game from orbit
*