Advertisement
Guest User

Untitled

a guest
Apr 29th, 2016
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. //Block = Asuka
  2. //Ball = Bunny
  3. //Ballz = Bunz
  4. //Bunny is linked in library
  5. import flash.events.Event;
  6.  
  7. var intervalBunny = setInterval(addBunny, 1000);
  8.  
  9. var bunz: Array = [];
  10.  
  11. function addBunny() {
  12. var bunny: Bunny = new Bunny();
  13. bunny.x = Math.ceil(Math.random() * 500);
  14. bunny.y = -50;
  15. addChild(bunny);
  16. bunz.push(bunny);
  17. bunny.addEventListener(Event.ENTER_FRAME, dropBunny);
  18. }
  19.  
  20. function dropBunny(e: Event) {
  21. var b: Bunny = Bunny(e.target);
  22. b.y += 10;
  23. if (b.y > 400) {
  24. eliminatebunz(b);
  25. }
  26. }
  27.  
  28. stage.addEventListener(Event.ENTER_FRAME, moveAsuka);
  29.  
  30. function moveAsuka(e: Event) {
  31. Asuka.x = mouseX;
  32. for (var i: int = 0; i < bunz.length; i++) {
  33. trace(i);
  34. if (Asuka.hitTestObject(bunz[i])) {
  35. eliminatebunz(bunz[i]);
  36. //points
  37. }
  38. }
  39. }
  40.  
  41. function eliminatebunz(p) {
  42.  
  43. p.removeEventListener(Event.ENTER_FRAME, dropBunny);
  44. removeChild(p);
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement