neirao

Untitled

Oct 16th, 2015
97
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;//need only 1 time!!
  7. menuplay.addEventListener(TouchEvent.TOUCH_TAP, playgame);
  8. function playgame(event:TouchEvent):void{  
  9.     //gotoAndPlay(2);//better only GOTO AND STOP..
  10.     gotoAndStop(2);
  11. }
  12.  
  13.  
  14.  
  15.  
  16.  
  17. //=======================================
  18. // FRAME 2
  19. //=======================================
  20.  
  21. stop()
  22. //Multitouch.inputMode = MultitouchInputMode.TOUCH_POINT;//no need here too..
  23. //removeChild(menus);//no need remove we use VISIBLE!!
  24. //removeChild(backgame);//no need remove we use VISIBLE!!
  25.  
  26. menus.visible = false;
  27. backgame.visible = false;
  28.  
  29. var lompat = false;
  30. var loncat = 30;
  31. var gravitasi = 6;
  32. var batasAtas = 350;
  33. var playerScore: int = 0;
  34.  
  35. var game_paused: Boolean = false; //@new
  36.  
  37. pauseBT.addEventListener(TouchEvent.TOUCH_TAP, pause_menu);
  38. home.addEventListener(TouchEvent.TOUCH_TAP, home_menu);
  39. backgame.addEventListener(TouchEvent.TOUCH_TAP, remove_pause);
  40. tombol.addEventListener(TouchEvent.TOUCH_TAP, fl_TapHandler_4);//????
  41.  
  42. addEventListener(Event.ENTER_FRAME, loop); //add loop
  43. //addEventListener(Event.ENTER_FRAME, fl_EnterFrameHandler_2);//need only 1 loop(enterframe function)
  44.  
  45. function pause_menu(event: TouchEvent): void {
  46.     trace("btname:",event.target.name);//temp  
  47.     menus.visible = true; //visible AGAIN
  48.     backgame.visible = true; //visible AGAIN
  49.     //-------------------------
  50.     pauseBT.visible=false;
  51.     //-------------------------
  52.     game_paused=true;      
  53.     //stage.frameRate = 0; 
  54.     player.stop();
  55. }
  56. function remove_pause(event: TouchEvent): void {
  57.     trace("btname:",event.target.name);//temp
  58.     //stage.frameRate = 24;
  59.     //removeChild(menus);//no need  //removeChild(backgame);//no need
  60.     menus.visible = false;
  61.     backgame.visible = false;
  62.     //-------------------------
  63.     game_paused=false; 
  64.     pauseBT.visible=true;
  65.     player.play();
  66. }
  67. function home_menu(event: TouchEvent): void {
  68.     trace("btname:",event.target.name);//temp
  69.     //addChild(menus);  //addChild(backgame);   //-menus.visible = true; //visible AGAIN//--backgame.visible = true; //visible AGAIN   
  70.     //no need - all objects are position right, only invisble!  //menus.x = 400;    //menus.y = 240;    //backgame.x = 410; //backgame.y = 200;
  71.     removeEventListener(Event.ENTER_FRAME, loop); //remove loop - in first frame no use..
  72.     gotoAndStop(1);
  73.     //stage.frameRate = 0;
  74. }
  75. function fl_TapHandler_4(event: TouchEvent) {
  76.     trace("btname:",event.target.name);//temp
  77.     trace("testignaifwa")
  78.     lompat = true;
  79. }
  80. function loop(event: Event): void {
  81.     if (!game_paused) {
  82.         if (lompat) {
  83.             player.y -= loncat;
  84.             loncat -= gravitasi;
  85.             if (player.y > batasAtas) {
  86.                 //nilai variable melompat diubah menjadi false
  87.                 lompat = false;
  88.                 //nilai variable loncatan diubah menjadi 30 kembali
  89.                 loncat = 30;
  90.             }
  91.         }
  92.         a.x -= 10;
  93.         if (player.hitTestObject(a) == true) {
  94.             playerScore += 10;
  95.             updateTextFields();
  96.         }
  97.     } else {
  98.         trace("game paused!");
  99.     }
  100. }
  101.  
  102. function updateTextFields(): void {
  103.     playerScoreText.text = ("SCORE :" + playerScore);
  104. }
RAW Paste Data