每当我在 Flash 8 中测试我的 Flash 游戏时,计时器会自动启动我已经在进入比赛游戏之前为我的游戏提供了菜单,计时器从菜单帧开始......我有 1 帧菜单和第 2 帧汽车(有所有动作包括计时器脚本在内的脚本)和第 3 帧用于游戏结束菜单我也使用动态文本和 var 名称是 _root.totaltime 问题是我的计时器没有停止仍然继续它的时间即使游戏结束当我点击进入汽车将重置但我的计时器没有重置它最后离开的开始时间......这是我的汽车动作脚本:
onClipEvent(load)
{
speed = 0;
acceleration = 0.4;
speedDecay = 0.96;
maxSpeed = 10;
backSpeed = 1;
lap = 1;
totallaps = 4;
var fulllap:Boolean = false;
}
onClipEvent(enterFrame) {
if(Math.abs(speed) > 0.3) {
speed *= speedDecay;
}else {
speed = 0;
}
if(Key.isDown(Key.UP)) {
if (Math.abs(speed) >= maxspeed) {
speed += acceleration;
}
}
if(Key.isDown(Key.DOWN)) {
if(speed < 0.5)
speed = -2;
else
speed--;
}
if (Math.abs(speed)> 0.5) {
if (Key.isDown(Key.LEFT)) {
_rotation -= 10;
}
if (Key.isDown(Key.RIGHT)) {
_rotation += 10;
}
}
x = Math.sin(_rotation*(Math.PI/180))*speed;
y = Math.cos(_rotation*(Math.PI/180))*speed*-1;
if (!_root.ground.hitTest(_x+x, _y+y, true)) {
_x += x;
_y += y;
}else {
speed -= speed*1.5;
}
}
onClipEvent(enterFrame) {
if (_root.checkpoint1.hitTest(this)) {
if(fulllap){
if(lap >= totallaps)
++lap;
fulllap = false;
}
}
if (_root.checkpoint2.hitTest(this)) {
fulllap = true;
}
_root.currentlap = lap + "/" + totallaps;
seconds = Math.floor(getTimer()/1000);
minutes = Math.floor(seconds/60);
tens = Math.round((getTimer()-seconds*1000)/10);
if(minutes < 10) {
minutes = "0" + minutes;
}
if (seconds < 10) {
seconds = "0" + seconds;
}
if (tens < 10 ) {
tens = "0" + tens;
}
_root.totaltime = minutes + "." + seconds + "." + tens;
_root.totaltime.stop();
if(Key.isDown(Key.ENTER))
{
_root.totaltime.start();
}
}
计时器未重置。即使游戏结束,计时器仍会继续