mirror of
https://github.com/photonstorm/phaser
synced 2024-11-27 15:12:18 +00:00
Renamed to Update Manager.
This commit is contained in:
parent
f9ffe098c3
commit
15fbd0962d
5 changed files with 58 additions and 22 deletions
|
@ -173,9 +173,10 @@ EOL;
|
|||
|
||||
<script src="$path/src/components/BaseTransform.js"></script>
|
||||
<script src="$path/src/components/Children.js"></script>
|
||||
<script src="$path/src/components/Color.js"></script>
|
||||
<script src="$path/src/components/Data.js"></script>
|
||||
<script src="$path/src/components/Transform.js"></script>
|
||||
<script src="$path/src/components/TransformManager.js"></script>
|
||||
<script src="$path/src/components/UpdateManager.js"></script>
|
||||
|
||||
<script src="$path/src/gameobjects/Factory.js"></script>
|
||||
<script src="$path/src/gameobjects/GameObjectCreator.js"></script>
|
||||
|
|
|
@ -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)
|
|
@ -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();
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
|
@ -595,6 +595,7 @@ Phaser.StateManager.prototype = {
|
|||
{
|
||||
this._created = true;
|
||||
this.onCreateCallback.call(this.callbackContext, this.game);
|
||||
this.game.updates.running = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
|
@ -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
|
||||
},
|
||||
|
||||
|
|
Loading…
Reference in a new issue