Advertisement
neirao

Untitled

Oct 16th, 2015
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. //=======================================
  3. // FRAME 1
  4. //=======================================
  5. stop();
  6. Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;
  7. menuplay.addEventListener(TouchEvent.TOUCH_TAP, playgame);
  8. function playgame(event: TouchEvent): void {
  9.     gotoAndStop(2);
  10. }
  11.  
  12. //=======================================
  13. // FRAME 2
  14. //=======================================
  15. stop();
  16. menus.visible = false;
  17. backgame.visible = false;
  18. var lompat = false;
  19. var loncat = 30;
  20. var gravitasi = 6;
  21. var batasAtas = 350;
  22. var playerScore: int = 0;
  23. var game_paused: Boolean = false;
  24.  
  25. pauseBT.addEventListener(TouchEvent.TOUCH_TAP, pause_menu);
  26. home.addEventListener(TouchEvent.TOUCH_TAP, home_menu);
  27. backgame.addEventListener(TouchEvent.TOUCH_TAP, remove_pause);
  28. tombol.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_4);
  29. addEventListener(Event.ENTER_FRAME, loop);
  30.  
  31. function pause_menu(event: TouchEvent): void {
  32.     trace("btname:", event.target.name);
  33.     menus.visible = true;
  34.     backgame.visible = true;
  35.     pauseBT.visible = false;
  36.     game_paused = true;
  37.     player.stop();
  38. }
  39. function remove_pause(event: TouchEvent): void {
  40.     trace("btname:", event.target.name);
  41.     menus.visible = false;
  42.     backgame.visible = false;
  43.     game_paused = false;
  44.     pauseBT.visible = true;
  45.     player.play();
  46. }
  47. function home_menu(event: TouchEvent): void {
  48.     trace("btname:", event.target.name);
  49.     removeEventListener(Event.ENTER_FRAME, loop);
  50.     gotoAndStop(1);
  51. }
  52. function fl_TapHandler_4(event: TouchEvent) {
  53.     trace("btname:", event.target.name);
  54.     trace("testignaifwa")
  55.     lompat = true;
  56. }
  57. function loop(event: Event): void {
  58.     if (!game_paused) {
  59.         if (lompat) {
  60.             player.y -= loncat;
  61.             loncat -= gravitasi;
  62.             if (player.y > batasAtas) {
  63.                 lompat = false;
  64.                 loncat = 30;
  65.             }
  66.         }
  67.         a.x -= 10;
  68.         if (player.hitTestObject(a) == true) {
  69.             playerScore += 10;
  70.             updateTextFields();
  71.         }
  72.     } else {
  73.         trace("game paused!");
  74.     }
  75. }
  76. function updateTextFields(): void {
  77.     playerScoreText.text = ("SCORE :" + playerScore);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement