我正在尝试使用动作脚本3创建游戏,并且无法理解为什么以下代码导致我的分数立即重置为0并且我的计时器快速更改数字而没有一致的模式?任何帮助深表感谢!谢谢!
import flash.events.Event;
import flash.events.MouseEvent;
import flash.utils.Timer;
import flash.events.TimerEvent;
var score:int=0;
var nCount:Number = 5;
var myTimer:Timer = new Timer(3000, nCount);
timer_txt.text = nCount.toString();
myTimer.addEventListener(TimerEvent.TIMER, countdown);
myTimer.start();
function countdown(e:TimerEvent):void{
nCount--;
timer_txt.text = nCount.toString();
}
init();
function init(): void {
Mouse.hide();
addEventListener(Event.ENTER_FRAME, update);
addEventListener(MouseEvent.CLICK, checkIfHit);
}
function update(myEvent:Event):void{
aim_mc.x = this.mouseX;
aim_mc.y = this.mouseY;
score_txt.text = "Score: " + score;
}
function checkIfHit(e:MouseEvent):void{
for(var i:int = 1; i < 4;++i){
var myClip:MovieClip = MovieClip(getChildByName("duck" + i));
if (myClip.hitTestPoint(mouseX,mouseY,true)){
score = score + 1;
}
}
}