SonOfChaos
06-27-2009, 09:52 AM
Okay, I've got a healthbar that shrinks everytime a character is hit when an object becomes larger than a certain size. This is in an enter_frame, basically the healthbar shrinks every frame, when I want it to shrink ONCE and then stop until hit again. I used a boolean value set to false to control it so I thought. Argh.The current behavior is that is shrinks, stops, and then shrinks again, like the boolean variable turning itself off then on repeatedly quickly. I've tried moving the else statement to no avail.
collisionOne is a boolean that = false;
//This is in an enterframe event.
for(var e=0; e<boxArray.length; e++){
if(boxArray[e].scaleX > 2){
boxArray[e].die();
if(! collisionOne){
trace('collision One');
hbar.width -=5;
collisionOne = true;
} else {
collisionOne = false;
}
}
}
collisionOne is a boolean that = false;
//This is in an enterframe event.
for(var e=0; e<boxArray.length; e++){
if(boxArray[e].scaleX > 2){
boxArray[e].die();
if(! collisionOne){
trace('collision One');
hbar.width -=5;
collisionOne = true;
} else {
collisionOne = false;
}
}
}