1

我正在开发一个游戏,其中创建了“进程”,并且他们创建了自己的计时器。一旦计时器完成,就会向服务器发送一个请求“处理完成”。有时问题是计时器提前结束,因为在我的测试环境中,客户端和服务器在同一台机器上,一切都发生得非常快,服务器无法检查进程是否过期。

这是因为 actionscript 的 Timer 调度的计时器提前完成了一点。现在,我看到了很多关于这个问题的文章,包括这篇文章,但这些似乎都没有回答我的问题。我不想创建一个准确的计时器,而是创建一个永远不会提前调度的计时器,无论客户端在运行时是否以略高的 FPS 速率运行。我该如何做到这一点?谢谢!

4

1 回答 1

0

Use Date.getTime() when creating the timer and when the timer is done. Subtract the second value from the first. This gives you the amount of time that has passed (in milliseconds). If the value is less than it should be, don't dispatch the event.

于 2013-05-28T09:43:54.227 回答