From f593afd1643a30f20ded7700516333fe51a3b658 Mon Sep 17 00:00:00 2001 From: Mario Gonzalez Date: Tue, 1 Oct 2013 10:08:09 -0400 Subject: [PATCH] Fixed accidentally overwroting remove function with a prepend function --- src/core/LinkedList.js | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/src/core/LinkedList.js b/src/core/LinkedList.js index 23eb1d1c..7b302cae 100644 --- a/src/core/LinkedList.js +++ b/src/core/LinkedList.js @@ -38,17 +38,14 @@ Phaser.LinkedList.prototype = { }, remove: function (child) { - if( this.first ) { - child.next = this.last.next; - child.prev = this.last; - if( this.last.next ) { - this.last.next.prev = child; - } - this.last.next = child; - this.last = this.last.next; - } else { - this.first = this.last = child; - } + if( child == this.first ) this.first = this.first.next; // It was 'first', make 'first' point to first.next + else if ( child == this.last ) this.last = this.last.prev; // It was 'last', make 'last' point to last.prev + + if( child.prev ) child.prev.next = child.next; // make child.prev.next point to childs.next instead of child + if( child.next ) child.next.prev = child.prev; // make child.next.prev point to child.prev instead of child + child.next = child.prev = null; + + if( this.first == null ) this.last = null; this.total--; },