Okay, I’m making a game, and it has an onEnterFrame which checks each players status (hp and turn), and decides what to do based on that. Looks like this:
_root.onEnterFrame = function() {
if(enemy.HP>0) {
if(hero.HP>0) {
if(hero.turn==0) {
actionBox.actionSet.enabled = true;
playerTurn();
} else if(enemy.turn==0) {
enemy.clip._alpha = 100;
enemy.clip.enabled = false;
actionBox.actionSet.enabled = false;
enemyTurn();
}
} else {
enemyWin();
}
} else {
playerWin();
}
}
So this works fine when it’s the players turn. But when it’s the enemy’s turn, the enemy simply attacks a bunch till hero.HP<0 and enemy wins. I am certain this is because it’s checking each frame to see if it’s the enemies turn and then it executes the hitting code before the turn is changed (which must mean this is freakin fast, so cool, but not good for me here!).
I tried simply making a function to call at the end of the attack, with a function that happens only on first turn to let the player initiate, but when then the hero makes no attack, enemy attacks and there is a recursion error and it shuts down. So thats no good…?
I don’t know what to do. Any ideas?
thanks!