发现差异游戏 - 如何创建获胜屏幕(点击计数器进入下一阶段)

时间:2013-12-20 16:18:48

标签: actionscript-3 flash actionscript

我正在为不同的游戏创建一个简单的位置(只有一个级别)。单击不同的点时,将出现一个旋转圆圈并突出显示该点。 我已经开发了上述功能,并开发了计时器倒计时。

然而,当我尝试开发这个功能时,在找到所有斑点之后,它会移动到下一帧“3”,显示“你赢了”,并开发了生命倒计时(如果点击点除了5现场上面,生活将减少到0),它不起作用。 你能帮我检查一下我的代码有什么问题吗?

此外,我想询问是否有另一种方法可以进行获胜屏幕(点击所有点后,它将自动指向获胜屏幕)和生活计数器,如上所述。 (如果点击5个不同点之外的点,就会失去一条生命)

以下是我游戏的打印屏幕。

i43.tinypic.com/2dt12jn.jpg右侧的圆圈为mv_check_d1,左侧为mv_check_d6。

i41.tinypic.com/2z8n41h.jpg正如您所看到的,在我点击所有位置后,它并未指向获胜者屏幕,并且计时器倒计时仍在运行。

这是我的代码:

注意: btn_click_d1是我的按钮,放在不同的位置。单击它时,符号mv_check_d1(红色圆圈)将围绕该点旋转。

gotoAndStop(2)指向游戏框架。

gotoAndStop(3)指向Winning / Congratulation框架。

 stop();

import flash.events.MouseEvent;

//Create event for the button when being clicked/touched on
btn_click_d1.addEventListener(MouseEvent.CLICK, click_d1);
    function click_d1 (event:MouseEvent):void{
        mv_check_d1.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d1.removeEventListener(MouseEvent.CLICK, click_d1);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d1.useHandCursor = false;

//when click button 1, the checkpoint will also appear on the left screen
btn_click_d1.addEventListener(MouseEvent.CLICK, click_d6);
    function click_d6 (event:MouseEvent):void{
        mv_check_d6.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d1.removeEventListener(MouseEvent.CLICK, click_d6);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d1.useHandCursor = false; 

btn_click_d2.addEventListener(MouseEvent.CLICK, click_d2);
    function click_d2 (event:MouseEvent):void{
        mv_check_d2.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d2.removeEventListener(MouseEvent.CLICK, click_d1);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d2.useHandCursor = false;

btn_click_d3.addEventListener(MouseEvent.CLICK, click_d3);
    function click_d3 (event:MouseEvent):void{
        mv_check_d3.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d3.removeEventListener(MouseEvent.CLICK, click_d3);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d3.useHandCursor = false;

btn_click_d4.addEventListener(MouseEvent.CLICK, click_d4);
    function click_d4 (event:MouseEvent):void{
        mv_check_d4.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d4.removeEventListener(MouseEvent.CLICK, click_d4);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d4.useHandCursor = false;

btn_click_d5.addEventListener(MouseEvent.CLICK, click_d5);
    function click_d5 (event:MouseEvent):void{
        mv_check_d5.gotoAndPlay(1);

        //After operating event, remove the button
        btn_click_d5.removeEventListener(MouseEvent.CLICK, click_d5);

        //After clicking, also remove the button so that the user will not click it twice

        }
        btn_click_d5.useHandCursor = false;

//1.
var count:Number = 30;

//2.
var myTimer:Timer = new Timer(1000,count);

//3.
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete); 
//4.
myTimer.start();

//5.
function countdown(event:TimerEvent):void {
myText_txt.text = String((count)-myTimer.currentCount);
}

function onTimerComplete(e:TimerEvent):void{
myTimer.removeEventListener(TimerEvent.TIMER_COMPLETE, onTimerComplete);

gotoAndStop(2);
}

//nextlevel and life countdown

var NextLevelCounter:int = 0; 
var LivesCounter:int = 3;
function clickListener(e:MouseEvent):void {
   if(btn_click_d1.hitTestPoint(e.localX, e.localY) || btn_click_d2.hitTestPoint(e.localX, e.localY) || btn_click_d3.hitTestPoint(e.localX, e.localY) || btn_click_d4.hitTestPoint(e.localX, e.localY) || btn_click_d5.hitTestPoint(e.localX, e.localY)){

      ++NextLevelCounter;
   }
   else{
      --LivesCounter;
   }

   if(NextLevelCounter == 5)
      goToNextLevel();
   if(LivesCounter == 0)
      lose();
}

 function goToNextLevel():void{ 
    gotoAndStop(3);
 }
  function lose():void{
     gotoAndStop(2); 
  }

0 个答案:

没有答案