Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. private var goblin1:Goblin = new Goblin();
  2. private var goblin2:Goblin = new Goblin();
  3. private var goblin3:Goblin = new Goblin();
  4.  
  5. private var aGoblinArray = new Array(container.goblin1, container.goblin2, container.goblin3);
  6.  
  7. for (var i:int = 0; i < aGoblinArray.length; i++)
  8. {
  9. var goblin:Goblin = aGoblinArray[i];
  10. }
  11.  
  12. if (goblin.hitTestPoint(_character.x + 100, _character.y - 45, true))
  13. {
  14. goblinCanMove = false;
  15. trace("lance hits");
  16. //hitOnce
  17. if (!hitOnce)
  18. {
  19. hitOnce = true;
  20. trace("take on damage");
  21. }
  22. goblin.moveBack();
  23. goblin.minusHealth();
  24. }
  25.  
  26. public static var goblinLife; int;
  27.  
  28. goblinLife = 2;//put in main constructor
  29.  
  30. public function minusHealth():void
  31. {
  32. goblinLife --;
  33. checkDeath();
  34. }
  35.  
  36. private function checkDeath():void
  37. {
  38. if (goblinLife == 0)
  39. {
  40. parent.removeChild(this);
  41. }
  42. }
  43.  
  44. public static var goblinLife; int;
  45.  
  46. private var goblinLife; int;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement