动作3如何跟踪时间过去了?动作、时间

由网友(我敢素颜小白衫帆布鞋溜达)分享简介:即时通讯新的ActionScript3闪光灯。我有一个int变量,我想补充+2每一秒,因为比赛开始。我怎样才能做到这一点?我怎么知道多少时间已经过去了?在此先感谢!im new to actionscript3 flash. I have a int variable and i would like to add...

即时通讯新的ActionScript3闪光灯。我有一个int变量,我想补充+2每一秒,因为比赛开始。我怎样才能做到这一点?我怎么知道多少时间已经过去了?在此先感谢!

im new to actionscript3 flash. I have a int variable and i would like to add +2 every second since game started. How can i do this ? how do i know how much time has elapsed? thanks in advance!

推荐答案

的getTimer()将返回到底有多少距离时,闪光灯开始毫秒一个int。

getTimer() will return an int of exactly how many milliseconds from when flash started.

import flash.utils.getTimer;

var myInt:int = getTimer() * 0.001;

现在敏将然而,许多秒的程序已经运行。

myInt will now be however many seconds the program has been running.

编辑:哦,告诉它已经运行了多长时间只是保持初始敏,并检查它针对当前定时器

edit: oh to tell how long it has been running just keep the initial myInt and check it against the current timer.

因此​​本场比赛第一次启动的时候。

so when the game first starts.

var startTime:int = getTimer();

然后每一帧或当你需要检查一下。

then every frame or whenever you need to check it.

var currentTime:int = getTimer();


var timeRunning:int = (currentTime - startTime) * 0.001; // this is how many seconds the game has been running.
阅读全文

相关推荐

最新文章