Skip to content

Commit 5416dea

Browse files
committed
The UpdateList.remove method wouldn't flag the Game Object for removal properly if it was active. It now checks that the Game Object is in the current update list and hasn't already been inserted into the 'pending removal' list before flagging it. Fix phaserjs#4544
1 parent deca3c9 commit 5416dea

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

src/gameobjects/UpdateList.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -193,9 +193,12 @@ var UpdateList = new Class({
193193
*/
194194
update: function (time, delta)
195195
{
196-
for (var i = 0; i < this._list.length; i++)
196+
var list = this._list;
197+
var length = list.length;
198+
199+
for (var i = 0; i < length; i++)
197200
{
198-
var gameObject = this._list[i];
201+
var gameObject = list[i];
199202

200203
if (gameObject.active)
201204
{
@@ -216,9 +219,7 @@ var UpdateList = new Class({
216219
*/
217220
remove: function (child)
218221
{
219-
var index = this._pendingRemoval.indexOf(child);
220-
221-
if (index !== -1)
222+
if (this._list.indexOf(child) !== -1 && this._pendingRemoval.indexOf(child) === -1)
222223
{
223224
this._pendingRemoval.push(child);
224225
}

0 commit comments

Comments
 (0)