Skip to content

Commit 8bc485e

Browse files
committed
Renamed internal array and only call GameObject.preUpdate on active list items.
1 parent 7d12c6c commit 8bc485e

1 file changed

Lines changed: 13 additions & 10 deletions

File tree

v3/src/plugins/UpdateList.js

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var UpdateList = new Class({
88
{
99
this.state = state;
1010

11-
this._active = [];
11+
this._list = [];
1212
this._pendingInsertion = [];
1313
this._pendingRemoval = [];
1414
},
@@ -37,19 +37,19 @@ var UpdateList = new Class({
3737
{
3838
gameObject = this._pendingRemoval[i];
3939

40-
var index = this._active.indexOf(gameObject);
40+
var index = this._list.indexOf(gameObject);
4141

4242
if (index > -1)
4343
{
44-
this._active.splice(index, 1);
44+
this._list.splice(index, 1);
4545
}
4646

4747
// Pool them?
4848
// gameObject.destroy();
4949
}
5050

5151
// Move pending to active
52-
this._active = this._active.concat(this._pendingInsertion.splice(0));
52+
this._list = this._list.concat(this._pendingInsertion.splice(0));
5353

5454
// Clear the lists
5555
this._pendingRemoval.length = 0;
@@ -58,11 +58,14 @@ var UpdateList = new Class({
5858

5959
update: function (time, delta)
6060
{
61-
for (var i = 0; i < this._active.length; i++)
61+
for (var i = 0; i < this._list.length; i++)
6262
{
63-
var gameObject = this._active[i];
63+
var gameObject = this._list[i];
6464

65-
gameObject.preUpdate.call(gameObject, time, delta);
65+
if (gameObject.active)
66+
{
67+
gameObject.preUpdate.call(gameObject, time, delta);
68+
}
6669
}
6770
},
6871

@@ -76,17 +79,17 @@ var UpdateList = new Class({
7679
this._pendingInsertion[i].destroy();
7780
}
7881

79-
for (i = 0; i < this._active.length; i++)
82+
for (i = 0; i < this._list.length; i++)
8083
{
81-
this._active[i].destroy();
84+
this._list[i].destroy();
8285
}
8386

8487
for (i = 0; i < this._pendingRemoval.length; i++)
8588
{
8689
this._pendingRemoval[i].destroy();
8790
}
8891

89-
this._active.length = 0;
92+
this._list.length = 0;
9093
this._pendingRemoval.length = 0;
9194
this._pendingInsertion.length = 0;
9295
},

0 commit comments

Comments
 (0)