diff --git a/build/config.php b/build/config.php
index d8d33080f..b2d1f6243 100644
--- a/build/config.php
+++ b/build/config.php
@@ -173,9 +173,10 @@ EOL;
+
-
+
diff --git a/src/components/TransformManager.js b/src/components/UpdateManager.js
similarity index 53%
rename from src/components/TransformManager.js
rename to src/components/UpdateManager.js
index d43bc647f..716524e11 100644
--- a/src/components/TransformManager.js
+++ b/src/components/UpdateManager.js
@@ -9,28 +9,56 @@
*
* @class
*/
-Phaser.TransformManager = function (game)
+Phaser.UpdateManager = function (game)
{
this.game = game;
this.list = [];
+
+ this.i = 1;
+
+ this.running = false;
this.processed = 0;
};
-Phaser.TransformManager.prototype.constructor = Phaser.TransformManager;
+Phaser.UpdateManager.prototype.constructor = Phaser.UpdateManager;
-Phaser.TransformManager.prototype = {
+Phaser.UpdateManager.prototype = {
- preUpdate: function ()
+ stop: function ()
{
- this.processed = 0;
+ if (!this.running)
+ {
+ return;
+ }
+
+ // console.log(this.i, 'UpdateManager.stop', this.processed);
+
this.list.length = 0;
+
+ this.i++;
},
- update: function ()
+ start: function ()
{
- for (var i = 0; i < this.list.length; i++)
+ if (!this.running)
+ {
+ return;
+ }
+
+ var len = this.list.length;
+
+ if (len === 0)
+ {
+ return;
+ }
+
+ // console.log(this.i, 'UpdateManager.start', len);
+
+ this.processed = 0;
+
+ for (var i = 0; i < len; i++)
{
// Because it may have already been processed (as a child of another Transform that was updated)
if (this.list[i] && this.list[i]._dirty)
@@ -39,7 +67,6 @@ Phaser.TransformManager.prototype = {
this.list[i].update();
}
}
-
},
add: function (transform)
diff --git a/src/core/Game.js b/src/core/Game.js
index a7ec5fb8a..78c5dc24f 100644
--- a/src/core/Game.js
+++ b/src/core/Game.js
@@ -220,9 +220,9 @@ Phaser.Game = function (width, height, renderer, parent, state, pixelArt)
this.textures = null;
/**
- * @property {Phaser.TransformManager} transforms - Reference to the Phaser Transform Manager.
+ * @property {Phaser.UpdateManager} updates - Reference to the Phaser Update Manager.
*/
- this.transforms = null;
+ this.updates = null;
/**
* @property {Phaser.Cache} cache - Reference to the assets cache.
@@ -605,7 +605,7 @@ Phaser.Game.prototype = {
}
};
- this.transforms = new Phaser.TransformManager(this);
+ this.updates = new Phaser.UpdateManager(this);
this.scale = new Phaser.ScaleManager(this, this._width, this._height);
this.stage = new Phaser.Stage(this);
@@ -833,6 +833,9 @@ Phaser.Game.prototype = {
update: function (time) {
this.time.update(time);
+ this.updateLogic(this.time.desiredFpsMult);
+ this.updateRender(this.time.slowMotion * this.time.desiredFps);
+ return;
if (this._kickstart)
{
@@ -939,7 +942,7 @@ Phaser.Game.prototype = {
this.pendingStep = true;
}
- this.transforms.preUpdate();
+ // this.updates.preUpdate();
this.scale.preUpdate();
this.debug.preUpdate();
@@ -997,20 +1000,17 @@ Phaser.Game.prototype = {
this.state.preRender(elapsedTime);
- // If this is empty then we could always NOT re-render the Canvas
- this.transforms.update();
+ this.updates.start();
- if (this.renderType !== Phaser.HEADLESS)
- {
- this.renderer.render(this.stage);
+ this.renderer.render(this.stage);
- this.plugins.render(elapsedTime);
+ this.plugins.render(elapsedTime);
- this.state.render(elapsedTime);
- }
+ this.state.render(elapsedTime);
this.plugins.postRender(elapsedTime);
+ this.updates.stop();
},
/**
diff --git a/src/core/StateManager.js b/src/core/StateManager.js
index 22aa04ec0..a81c383ef 100644
--- a/src/core/StateManager.js
+++ b/src/core/StateManager.js
@@ -595,6 +595,7 @@ Phaser.StateManager.prototype = {
{
this._created = true;
this.onCreateCallback.call(this.callbackContext, this.game);
+ this.game.updates.running = true;
}
else
{
diff --git a/src/renderer/canvas/CanvasRenderer.js b/src/renderer/canvas/CanvasRenderer.js
index 9a6c4b6a3..ebe86b87f 100644
--- a/src/renderer/canvas/CanvasRenderer.js
+++ b/src/renderer/canvas/CanvasRenderer.js
@@ -33,7 +33,7 @@ Phaser.Renderer.Canvas = function (game)
*/
this.clearBeforeRender = game.clearBeforeRender;
- this.dirtyRender = true;
+ this.dirtyRender = false;
/**
* Whether the render view is transparent
@@ -186,6 +186,11 @@ Phaser.Renderer.Canvas.prototype = {
*/
render: function (stage)
{
+ if (this.dirtyRender && this.game.updates.processed === 0)
+ {
+ return;
+ }
+
this.context.setTransform(1, 0, 0, 1, 0, 0);
// If the alpha or blend mode didn't change since the last render, then don't set them again
@@ -223,6 +228,8 @@ Phaser.Renderer.Canvas.prototype = {
stage.render(this, stage);
+ // console.log('render stage', this.game.updates.processed);
+
// Add Post-render hook
},