Hi
i’m experimenting a bit and noticed that when i remove an object from an array as followed:
private var list:Array<Actor>;
private var coin: Coin;
//game class
public function init() {
var x = 0;
var y = 0;
for (i in 0 ... 5) {
x += 30;
y += 30;
coin = new Coin(x, y, list);
list.push(coin);
}
for (actor in list) {
addChild(actor);
}
}
//sprite class
private function kill(event: MouseEvent): Void {
/*
list is referenced to an array of sprites -
this is an instance of a sprite within the list - AKA the coin
*/
list.remove(this);
}
everything works as expected. The object is removed from the list as can be seen in the output from:
trace(list.length)
However, the object(sprite that is drawn) still can be seen(its been drawn on the screen) even when the instance to that object has been removed.
Have I missed something?