forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUpdateManager.js
More file actions
79 lines (59 loc) · 1.42 KB
/
Copy pathUpdateManager.js
File metadata and controls
79 lines (59 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @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
*/
Phaser.UpdateManager = function (state)
{
this.state = state;
this.game = state.game;
this.list = [];
// this.i = 1;
this.running = false;
this.processed = 0;
};
Phaser.UpdateManager.prototype.constructor = Phaser.UpdateManager;
Phaser.UpdateManager.prototype = {
stop: function ()
{
if (!this.running)
{
return;
}
// console.log(this.i, 'UpdateManager.stop', this.processed);
this.list.length = 0;
// this.i++;
},
start: function ()
{
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)
{
this.processed++;
this.list[i].update();
}
}
},
add: function (transform)
{
this.list.push(transform);
}
};