Hey all, This problem has been racking our brain for a few hours so I thought I’d post it.
We’re running into the problem of deleting the players bullets correctly.
The problem consists of 3 objects:
conRoom [which is the controlling object of the room that, for example, creates ticks]
player [which is what you control]
bullets [which is what we’re trying to delete]
The way we’ve got it set up is that the player creates a bullet for the conRoom via “conRoom.addChild(bullet).” The bullet is fed a reference to both conRoom and player. In addition, the bullet passes a reference to a conRoom array via “conRoom.objectsArray.push(this)”
Then, when the bullet hits an enemy, we need it to be deleted. The way that we thought we had figured it out was by calling the conRoom function killAThing passing “this” as an argument:
public function killAThing(vO:GameObject):void {
if (vO!=null && this.contains(vO)) {
objectsArray.splice(objectsArray.indexOf(vO));
vO.parent.removeChild(vO);
vO=null;
}
}
So, the bullet appears to be removed, but is actually still there. I’m sure that this is a simple problem, from what we read, we’re removing the bullet from the play screen making it invisible but it’s still there…
But, I thought that vO=null solved that problem.
We’ve also tried doing the basic idea via eventListeners and we still can’t get it right.
I guess the idea is that we need to delete something that is stored in an array but we can’t seem to be able to do it…