我正在学习如何为我的游戏制作计时器。这就像"谁想成为百万富翁?"我有15个问题。每个问题有一个计时器:60秒....当我点击答案时,我继续下一帧,但我的计时器不会停止。当我找到答案时,我应该添加什么(以及在哪里)来停止我的计时器? (Flash Professional CS 5 / ActionScript 2)我的计时器代码是:
timer = 60;
countdown = function(){
_root.timer--;
if(_root.timer<=0){
gotoAndPlay(20); stop();
}
}
countdownInterval = setInterval(countdown,1000);
答案 0 :(得分:0)
答案 1 :(得分:-1)
试试这个
var timer:Timer = new Timer();
public function startTimer(n:Number):void{ //n = number of seconds you want to run the timer
t.repeatCount = n;
t.start();
t.addEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
}
public function timerComplete(event:TimerEvent):void{
t.removeEventListener(TimerEvent.TIMER_COMPLETE, timerComplete);
//What ever you want to do when timer is up.
}
希望它有所帮助!