2014-12-04 2 views
0

나는 여기에 이상한 상황이 있는데, 보통 이것에 문제가 없다.왜 내 버튼이 작동하지 않습니까?

상황은 이와 같이 4 개의 화면이 있습니다. 게임 화면, 메뉴 및 승리 화면 및 죽음 화면.

상황에 따라 플레이어가 승 화면에서 메뉴로 이동하는 데 사용할 수있는 버튼이 작동하지 않습니다. 나는 그것을 추적하고 버튼이 작동하고 있습니다. 단지 프레임을 움직이지 않습니다.

여기에 내가 사용한 코드가 있습니다.

public function prototype() { 

    } 
    public function startMenu() { 
     btnStart.addEventListener(MouseEvent.CLICK, gotoGame); 
    } 
    public function gotoGame(evt: MouseEvent): void { 
     btnStart.removeEventListener(MouseEvent.CLICK, gotoGame); 
     gotoAndStop("game1"); 
    } 
    public function gotoGameA(evt: MouseEvent): void { 
     btnContinue.removeEventListener(MouseEvent.CLICK, gotoGameA); 
     btnMenu.removeEventListener(MouseEvent.CLICK, gotoFront); 
     gotoAndStop("game1"); 
    } 
    public function gotoWin() { 
     gotoAndStop("win"); 
     startWin() 
    } 
    public function startWin() { 
     btnContinue.addEventListener(MouseEvent.CLICK, gotoGameA); 
     btnMenu.addEventListener(MouseEvent.CLICK, gotoFront); 
    } 
    public function gotoFront(evt: MouseEvent): void { 
     trace("please work") 
     gotoAndStop("menu"); 
     startMenu(); 
    } 
    public function gotoDeath() { 
     gotoAndPlay("death"); 
    } 

나는 이것을 어떻게 처리해야할지 모르겠다.

타임 라인 : 타임 라인없이

enter image description here

+0

는, 당신이이 권리/잘못된 config (설정)을 알고 어렵다. 또한,이 코드는 어디에 두어야합니까? – Raptor

+0

타임 라인의 이미지 게시를 시도했지만 충분한 포인트가 없습니다. 나는 게임의 메인 스크립트에 코드를 넣었다. –

+0

https://www.facebook.com/photo.php?fbid=10204164673536095&set=a.10204164673176086.1073741832.1204000217&type=3&permPage=1 –

답변

0
public function startMenu() { 
      btnStart.addEventListener(MouseEvent.CLICK, gotoGame); 
     } 

     private function gotoGame(evt: MouseEvent) { 
      btnStart.removeEventListener(MouseEvent.CLICK, gotoGame); 
      gotoAndStop("game1"); 
     } 
     private function gotoGameA(evt: MouseEvent) { 
      btnContinue.removeEventListener(MouseEvent.CLICK, gotoGame); 
      btnMenuA.removeEventListener(MouseEvent.CLICK, gotoMenu); 
      gotoAndStop("game1"); 
     } 
     public function startGameWin() { 
      btnMenuA.addEventListener(MouseEvent.CLICK, gotoMenu); 
      btnContinue.addEventListener(MouseEvent.CLICK, gotoGameA); 
     } 

     public function startGameOver() { 
      btnMenuB.addEventListener(MouseEvent.CLICK, gotoMenuA); 
     } 

     private function gotoMenu(evt: MouseEvent) { 
      trace("hit") 
      btnMenuA.removeEventListener(MouseEvent.CLICK, gotoMenu); 
      btnContinue.removeEventListener(MouseEvent.CLICK, gotoGame); 
      gotoAndStop("game1"); 
      gotoAndStop("menu"); 
     } 
     private function gotoMenuA(evt: MouseEvent) { 
      trace("hit") 
      btnMenuB.removeEventListener(MouseEvent.CLICK, gotoMenuA); 
      gotoAndStop("game1"); 
      gotoAndStop("menu"); 
     } 
관련 문제