Skip to content

Commit 15fbd09

Browse files
committed
Renamed to Update Manager.
1 parent f9ffe09 commit 15fbd09

5 files changed

Lines changed: 58 additions & 22 deletions

File tree

build/config.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,9 +173,10 @@
173173
174174
<script src="$path/src/components/BaseTransform.js"></script>
175175
<script src="$path/src/components/Children.js"></script>
176+
<script src="$path/src/components/Color.js"></script>
176177
<script src="$path/src/components/Data.js"></script>
177178
<script src="$path/src/components/Transform.js"></script>
178-
<script src="$path/src/components/TransformManager.js"></script>
179+
<script src="$path/src/components/UpdateManager.js"></script>
179180
180181
<script src="$path/src/gameobjects/Factory.js"></script>
181182
<script src="$path/src/gameobjects/GameObjectCreator.js"></script>
Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,56 @@
99
*
1010
* @class
1111
*/
12-
Phaser.TransformManager = function (game)
12+
Phaser.UpdateManager = function (game)
1313
{
1414
this.game = game;
1515

1616
this.list = [];
17+
18+
this.i = 1;
19+
20+
this.running = false;
1721

1822
this.processed = 0;
1923
};
2024

21-
Phaser.TransformManager.prototype.constructor = Phaser.TransformManager;
25+
Phaser.UpdateManager.prototype.constructor = Phaser.UpdateManager;
2226

23-
Phaser.TransformManager.prototype = {
27+
Phaser.UpdateManager.prototype = {
2428

25-
preUpdate: function ()
29+
stop: function ()
2630
{
27-
this.processed = 0;
31+
if (!this.running)
32+
{
33+
return;
34+
}
35+
36+
// console.log(this.i, 'UpdateManager.stop', this.processed);
37+
2838
this.list.length = 0;
39+
40+
this.i++;
2941
},
3042

31-
update: function ()
43+
start: function ()
3244
{
33-
for (var i = 0; i < this.list.length; i++)
45+
if (!this.running)
46+
{
47+
return;
48+
}
49+
50+
var len = this.list.length;
51+
52+
if (len === 0)
53+
{
54+
return;
55+
}
56+
57+
// console.log(this.i, 'UpdateManager.start', len);
58+
59+
this.processed = 0;
60+
61+
for (var i = 0; i < len; i++)
3462
{
3563
// Because it may have already been processed (as a child of another Transform that was updated)
3664
if (this.list[i] && this.list[i]._dirty)
@@ -39,7 +67,6 @@ Phaser.TransformManager.prototype = {
3967
this.list[i].update();
4068
}
4169
}
42-
4370
},
4471

4572
add: function (transform)

src/core/Game.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ Phaser.Game = function (width, height, renderer, parent, state, pixelArt)
220220
this.textures = null;
221221

222222
/**
223-
* @property {Phaser.TransformManager} transforms - Reference to the Phaser Transform Manager.
223+
* @property {Phaser.UpdateManager} updates - Reference to the Phaser Update Manager.
224224
*/
225-
this.transforms = null;
225+
this.updates = null;
226226

227227
/**
228228
* @property {Phaser.Cache} cache - Reference to the assets cache.
@@ -605,7 +605,7 @@ Phaser.Game.prototype = {
605605
}
606606
};
607607

608-
this.transforms = new Phaser.TransformManager(this);
608+
this.updates = new Phaser.UpdateManager(this);
609609

610610
this.scale = new Phaser.ScaleManager(this, this._width, this._height);
611611
this.stage = new Phaser.Stage(this);
@@ -833,6 +833,9 @@ Phaser.Game.prototype = {
833833
update: function (time) {
834834

835835
this.time.update(time);
836+
this.updateLogic(this.time.desiredFpsMult);
837+
this.updateRender(this.time.slowMotion * this.time.desiredFps);
838+
return;
836839

837840
if (this._kickstart)
838841
{
@@ -939,7 +942,7 @@ Phaser.Game.prototype = {
939942
this.pendingStep = true;
940943
}
941944

942-
this.transforms.preUpdate();
945+
// this.updates.preUpdate();
943946

944947
this.scale.preUpdate();
945948
this.debug.preUpdate();
@@ -997,20 +1000,17 @@ Phaser.Game.prototype = {
9971000

9981001
this.state.preRender(elapsedTime);
9991002

1000-
// If this is empty then we could always NOT re-render the Canvas
1001-
this.transforms.update();
1003+
this.updates.start();
10021004

1003-
if (this.renderType !== Phaser.HEADLESS)
1004-
{
1005-
this.renderer.render(this.stage);
1005+
this.renderer.render(this.stage);
10061006

1007-
this.plugins.render(elapsedTime);
1007+
this.plugins.render(elapsedTime);
10081008

1009-
this.state.render(elapsedTime);
1010-
}
1009+
this.state.render(elapsedTime);
10111010

10121011
this.plugins.postRender(elapsedTime);
10131012

1013+
this.updates.stop();
10141014
},
10151015

10161016
/**

src/core/StateManager.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,6 +595,7 @@ Phaser.StateManager.prototype = {
595595
{
596596
this._created = true;
597597
this.onCreateCallback.call(this.callbackContext, this.game);
598+
this.game.updates.running = true;
598599
}
599600
else
600601
{

src/renderer/canvas/CanvasRenderer.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Phaser.Renderer.Canvas = function (game)
3333
*/
3434
this.clearBeforeRender = game.clearBeforeRender;
3535

36-
this.dirtyRender = true;
36+
this.dirtyRender = false;
3737

3838
/**
3939
* Whether the render view is transparent
@@ -186,6 +186,11 @@ Phaser.Renderer.Canvas.prototype = {
186186
*/
187187
render: function (stage)
188188
{
189+
if (this.dirtyRender && this.game.updates.processed === 0)
190+
{
191+
return;
192+
}
193+
189194
this.context.setTransform(1, 0, 0, 1, 0, 0);
190195

191196
// 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 = {
223228

224229
stage.render(this, stage);
225230

231+
// console.log('render stage', this.game.updates.processed);
232+
226233
// Add Post-render hook
227234
},
228235

0 commit comments

Comments
 (0)