2014-12-04 130 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

没有一个时间表,这是很难知道你配置此正确/错误。另外,你把这段代码放在哪里? – Raptor 2014-12-04 07:09:37

+0

我尝试发布时间线的图像,但我没有足够的分数。我将代码放在游戏的主要脚本中。 – 2014-12-04 07:16:23

+0

https://www.facebook.com/photo.php?fbid=10204164673536095&set=a.10204164673176086.1073741832.1204000217&type=3&permPage=1 – 2014-12-04 07:19:10

回答

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"); 
     } 
相关问题