ScribbleFelix
09-11-2009, 08:23 AM
I wish to create a turn based combat system for a little game im currently making. Right now, i have the character you control via an attack button (player_mc), to do the appropriote attack animation and take down the enemy's health. but what im asking is:
how would i go about creating a timer that makes the enemy attack at random inervals of time, and whilst it is attacking, the player is unable to use his attacks.
i hope that makes sense.
here is my code so far.
thanks.
hitpoints=100
hp1_txt.text=hitpoints
hitpoints2=100
hp2_txt.text=hitpoints2
win_txt._visible=false;
attack_btn.onPress=function(){
_root.player_mc.gotoAndPlay("attack1");
hp2_txt.text-=Math.round(Math.random()*15)+1;
if(hp2_txt.text<0){
hp2_txt.text=0
win_txt._visible=true;
attack_btn.enabled=false;
}
}
how would i go about creating a timer that makes the enemy attack at random inervals of time, and whilst it is attacking, the player is unable to use his attacks.
i hope that makes sense.
here is my code so far.
thanks.
hitpoints=100
hp1_txt.text=hitpoints
hitpoints2=100
hp2_txt.text=hitpoints2
win_txt._visible=false;
attack_btn.onPress=function(){
_root.player_mc.gotoAndPlay("attack1");
hp2_txt.text-=Math.round(Math.random()*15)+1;
if(hp2_txt.text<0){
hp2_txt.text=0
win_txt._visible=true;
attack_btn.enabled=false;
}
}