0
我想在某個事件被觸發後重置我的計時器。目前,我有我在遊戲中的計時器,它會檢查該事件每4秒在我的更新內容如下:重置計時器在impactjs
timer: new ig.Timer(),
update:function(){
//console.log(this.timer.delta());
if (this.timer.delta() >= 0) {
this.performAchievementChecks();
this.timer.set(4);
}
},
performAchievementChecks:function(){
if(tempArray.length >= 1 && this.Achievements[achID].status == this.storage.get(achKey)){
this.performUpdate(achID);
}
}
performUpdate:function(achID){
this.timer.set(0);
this.updateAchievements(achID);
}
所以我的功能performAchievementchecks()
被稱爲每4秒,在這段時間內如果if語句去true
後來我想重置我的計時器回到0,但它不這樣做。有人能指出我做錯了什麼嗎?如果是這樣,在update()
之外的某個事件發生時,如何從其他不同的函數重置我的遊戲計時器?