特定のイベントがトリガーされた後、タイマーをリセットしようとしています。現在、次のように、アップデートで 4 秒ごとにそのイベントをチェックするゲーム内タイマーがあります。
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()
ですか?