Hello,
Having a problem with my game. I am running a hittest to see if my avatar hits a food movie clip. When it does I want to remove the child that has been hit. I have put all the food movieclips into an array called prey.
Currently what I have when my avatar hits a food it removes the whole array but I only want the food movie clip which has been hit to be removed.
Any ideas how I can do this?
Thanks in advance
var newFood:Food=new Food(650,randomyFood);
prey.push(newFood);
addChild(newFood);
var foodHasBeenHit:Boolean=false;
for each (var food:Food in prey) {
food.moveABit();
if (PixelPerfectCollisionDetection.isColliding(avatar,food,this,true)) {
foodHasBeenHit=true;
}
}
for(var i:int = 0; i<prey.length; i++)
if (foodHasBeenHit){
gameScore.addToValue(20);
prey*.parent.removeChild(prey*);
prey.splice(i, 1);
}