If statement & specific array element
So for a simple game I need to remove 1 life/heart when the player collides with the wall.
The first heart works, but the second only should be invisible after the first is already gone, and so on.
How do I state that? I now tried it with if-statements in a row, but that's probably not the way to do it.
And how do I equate with alpha and an array element? Or is there a more straight forward way?
I'd really appreciate your help! I'm still a beginner.
var wallArray:Array = new Array(wall1,wall2,wall3,wall4, wall5,sidewall1, sidewall2, sidewall3, sidewall4);
var heartArray:Array = new Array (heart1, heart2, heart3);
function collisionDetectPlayer(){
for(var i:uint = 0; i < wallArray.length;i++){
var wallTemp:MovieClip = wallArray;
if(player.hitTestObject(wallTemp)){
movePlayerBack();
heartArray[2].alpha = 0;
if ((heartArray[2]) < (alpha = 1)){
heartArray[1].alpha = 0;
if ((heartArray[1]) < (alpha = 1)){
heartArray[0].alpha = 0;
}
}
}
}
}
