2012-01-17 59 views
0

我正在制作游戏。该游戏基于一个非常小的时间间隔(你只有5个时间做动作)。我的计时器在Flash Player中很棒,我做了5次。在网页浏览器(firefox,safari ..)中,5秒计时器现在为8秒钟。Flash游戏:getTimer不准确

如何解决这个问题? 这里是我的代码,我显示时间:

private function updateTimer(e:TimerEvent) 
{ 
    if (this.timer.currentCount < 500) 
    { 
     var centiemes:int = 100 - Math.floor(this.timer.currentCount) % 100; 
     var secondes:int = 4 - Math.floor(this.timer.currentCount/100) % 60; 

     this.txtTemps.text = ToolBox.zeroFill(secondes.toString(), 2) + ":" + ToolBox.zeroFill(centiemes.toString(), 2); 
    } 
    else 
    { 
      this.txtTemps.text = "00:00"; 
      this.timer.stop();; 
    } 
} 

谢谢你!

+1

同样的问题呢? http://stackoverflow.com/questions/1014009/as3-how-accurate-are-the-gettimer-method-and-the-timer-class – MrKiane 2012-01-17 18:02:36

+0

不,看来Adobe必须有正确的。似乎Timer已经被放置,因为帧率基于处理器并且可以不同。 – 2012-01-18 09:26:50

回答

3

是计时器& setInterval不准确。

要获得准确的时间,您可以使用计算时间差&时间或您可以使用Audiotool团队使用的技术并使用音频文件。你可以找到更多信息herehere

+0

我会查看这些链接!谢谢 ! – 2012-01-18 09:27:06