mirror of
https://github.com/wassname/phaser.git
synced 2026-08-17 11:23:42 +08:00
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:
+44
-13
@@ -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
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user