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()
之外的某个事件发生时,如何从其他不同的函数重置我的游戏计时器?