我目前正在学习 ActionScript 3 的 Flash 游戏编程类(class),但似乎无法在任何地方找到可以倒计时然后执行 Action 的时钟。我一直在使用 Lynda 教程,但这没有帮助,我也在谷歌上搜索了很多,但没有运气。我有一个倒计时时钟,并尝试过“if”语句,但没有运气。
有人可以指导我正确的方向吗?我做错了什么?
//game timer
var count:Number = 60; // amount of time
var myTimer:Timer = new Timer(1000,count); // time in ms, count is calling from line above
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
function countdown(event:TimerEvent):void
{
myText_txt.text = String((count)-myTimer.currentCount); //dynamic txt box shows current count
}
//if and else if statements
if (((count)-myTimer.currentCount) == 58)
{
gotoAndStop(2);
}
最佳答案
这应该有帮助;)没有任何神奇的数字。
var myTimer:Timer = new Timer(1000,60); // every second for 60 seconds
myTimer.addEventListener(TimerEvent.TIMER, onTimer);
myTimer.addEventListener(TimerEvent.TIMER_COMPLETE, onComplete);
myTimer.start();
function onTimer(e: TimerEvent):void {
myText_txt.text = String(myTimer.repeatCount - myTimer.currentCount);
}
function onComplete(e: TimerEvent):void{
gotoAndStop(2);
}
关于actionscript-3 - AS 3 游戏结束屏幕闪光倒计时器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22141106/