teambuddies
12-27-2010, 04:01 PM
I got another problem.
In my game, my army walk then attack the enemy.
I use this hittest:
var hitenemy:Boolean = hitenemycheck(army);
if((hitenemy == true) && (army.attack == false))
{
army.xspeed = 0;
army.attack == true;
army.gotoAndPlay ("attack");
} else if ((hitenemy == false) && (army.attack == true)){
army.attack == false;
army.xspeed = 3;
Army.gotoAndPlay ("walk");
}
function hitenemycheck(objek:MovieClip):Boolean
{
for each (var enemy:MovieClip in enemy_arr){
if(objek.hitTestObject(enemy))
{
if (objek is efeksword1){
enemy.hp -= 1;
}
deletemc();
return true;
}
}
return false;
}
function deletemc():void{
for (var i:int=0;i<enemy_arr.length;i++){
if (enemy_arr[i].hp <=0){
removeChild(enemy_arr[i]);
enemy_arr.splice (i,1);
}
}
When the enemy die. my army start walk again and my problem is, my army won't attack the next enemy, my army just walk pass the enemy.
But when i try to make the enemy just walk pass my army (so the enemy don't die). my army will attack the next enemy (not pass it again).
what is the problem? is there any idea for the hittest?
Thanks
In my game, my army walk then attack the enemy.
I use this hittest:
var hitenemy:Boolean = hitenemycheck(army);
if((hitenemy == true) && (army.attack == false))
{
army.xspeed = 0;
army.attack == true;
army.gotoAndPlay ("attack");
} else if ((hitenemy == false) && (army.attack == true)){
army.attack == false;
army.xspeed = 3;
Army.gotoAndPlay ("walk");
}
function hitenemycheck(objek:MovieClip):Boolean
{
for each (var enemy:MovieClip in enemy_arr){
if(objek.hitTestObject(enemy))
{
if (objek is efeksword1){
enemy.hp -= 1;
}
deletemc();
return true;
}
}
return false;
}
function deletemc():void{
for (var i:int=0;i<enemy_arr.length;i++){
if (enemy_arr[i].hp <=0){
removeChild(enemy_arr[i]);
enemy_arr.splice (i,1);
}
}
When the enemy die. my army start walk again and my problem is, my army won't attack the next enemy, my army just walk pass the enemy.
But when i try to make the enemy just walk pass my army (so the enemy don't die). my army will attack the next enemy (not pass it again).
what is the problem? is there any idea for the hittest?
Thanks