0

我正在做一个计算点击次数然后添加分数的游戏。我想要的是添加一个计时器,例如:计时器为 10 秒,点击完成为 25,如果计时器停止按钮(用于计算点击次数的按钮),您的得分为 35 分无法点击并且它会暂停一段时间,计划在它移动到另一帧之前制作一个小动画。

想让这个尽可能简单,因为设计比代码更重要,因为它是一个设计基类。

请不要使用 hitTestObject 或类,我也想避免使用数组 :( 上次使用它们是一场灾难......

对不起,我是菜鸟,谢谢你的提前

这是代码:

 var power:Number = 0;
    var myTimer : Timer = new Timer(10 * 1000, 0);


    myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, function( e:TimerEvent ):void    
    {
        myTimer.start();
        trace("time up");
        bgBack.gotoAndPlay("hit");
        if (power == 5)
        {
        bgBack.gotoAndPlay("mini");
        }
        else if (power == 15)
        {
        bgBack.gotoAndPlay("mini");
        }
        else if (power == 25){
        bgBack.gotoAndPlay("belowAve");
        }
        else if (power == 35){
        bgBack.gotoAndPlay("ave");
        }
        else if (power == 50){
        bgBack.gotoAndPlay("ave");
        }
        else if (power == 65){
        bgBack.gotoAndPlay("highAve");
        }
        else if (power == 80){
        bgBack.gotoAndPlay("magni");
        }

});

pressBtn.addEventListener( MouseEvent.CLICK, function( e:MouseEvent ):void
{
   power++;

     if (power == 5)
    {
    gauge.gotoAndPlay("one");
    }
    else if (power == 15)
    {
    gauge.gotoAndPlay("two");
    }
    else if (power == 25){
    gauge.gotoAndPlay("three");
    }
    else if (power == 35){
    gauge.gotoAndPlay("four");
    }
    else if (power == 50){
    gauge.gotoAndPlay("five");
    }
    else if (power == 65){
    gauge.gotoAndPlay("six");
    }
    else if (power == 80){
    gauge.gotoAndPlay("seven");
    }
4

1 回答 1

0
var myTimer : Timer = new Timer( 10 * 1000, 0 );
myTimer.addEventListener( TimerEvent.TIMER_COMPLETE, function( e:TimerEvent ):void
{
    //here the timer ends and you can do stuff with the clicks.
    //the ,0 means it will repeat this over and over and over. 10 seconds * 1000 milliseconds because its kept in milliseconds.
});
myTimer.start();

并且

var myClicks : Number = 0;
stage.addEventListener( MouseEvent.CLICK, function( e:MouseEvent ):void
{
    myClicks++;
});
于 2013-06-29T21:29:30.167 回答