2016-10-14 03:09:07 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
|
|
|
* @copyright 2016 Photon Storm Ltd.
|
|
|
|
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Dirty! Manager
|
|
|
|
*
|
|
|
|
* @class
|
|
|
|
*/
|
2016-10-14 07:58:12 +00:00
|
|
|
Phaser.UpdateManager = function (game)
|
2016-10-14 03:09:07 +00:00
|
|
|
{
|
|
|
|
this.game = game;
|
|
|
|
|
|
|
|
this.list = [];
|
2016-10-14 07:58:12 +00:00
|
|
|
|
|
|
|
this.i = 1;
|
|
|
|
|
|
|
|
this.running = false;
|
2016-10-14 03:09:07 +00:00
|
|
|
|
|
|
|
this.processed = 0;
|
|
|
|
};
|
|
|
|
|
2016-10-14 07:58:12 +00:00
|
|
|
Phaser.UpdateManager.prototype.constructor = Phaser.UpdateManager;
|
2016-10-14 03:09:07 +00:00
|
|
|
|
2016-10-14 07:58:12 +00:00
|
|
|
Phaser.UpdateManager.prototype = {
|
2016-10-14 03:09:07 +00:00
|
|
|
|
2016-10-14 07:58:12 +00:00
|
|
|
stop: function ()
|
2016-10-14 03:09:07 +00:00
|
|
|
{
|
2016-10-14 07:58:12 +00:00
|
|
|
if (!this.running)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// console.log(this.i, 'UpdateManager.stop', this.processed);
|
|
|
|
|
2016-10-14 03:09:07 +00:00
|
|
|
this.list.length = 0;
|
2016-10-14 07:58:12 +00:00
|
|
|
|
|
|
|
this.i++;
|
2016-10-14 03:09:07 +00:00
|
|
|
},
|
|
|
|
|
2016-10-14 07:58:12 +00:00
|
|
|
start: function ()
|
2016-10-14 03:09:07 +00:00
|
|
|
{
|
2016-10-14 07:58:12 +00:00
|
|
|
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++)
|
2016-10-14 03:09:07 +00:00
|
|
|
{
|
|
|
|
// Because it may have already been processed (as a child of another Transform that was updated)
|
|
|
|
if (this.list[i] && this.list[i]._dirty)
|
|
|
|
{
|
|
|
|
this.processed++;
|
|
|
|
this.list[i].update();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
add: function (transform)
|
|
|
|
{
|
|
|
|
this.list.push(transform);
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|