Loop the collision on the body parts and break the procedure after the first collision is made.But wouldn't the sword detects multiple collisions? Like if it hits both body and head the damage would be counted twice. I guess it's fine if I use bullet since the bullet will disappear on collision.
You can.Well I don't know if as2 would allow typing a var as function
As Bluemagica suggested, simply create a static function for each type of attack:How does it know if it is shotgun or homing if I dont use switch case or if statement?
Give the character a variable such as:Code:function homingAttack(){...} function shotgunAttack(){...} ...etc
And when the weapon is changed, use the switch statement then to determine the attack and set the attack variable equal to the name of the function:Code:var attack:Function;
When the character attacks, then simply called the attack var as function:Code:function chooseAttack(weaponType:Number):void { switch(weaponType) { case 0: attack = shotgunAttack; break; case 1: attack = homingAttack; break; default: attack = meleeAttack; } }
Code:attack();




Reply With Quote