Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by peepli

Hello,

I am trying to reset my timer after a certain event is triggered. Currently I have my in-game timer which checks for that event every 4 seconds in my update as follows

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);
  }

So my function performAchievementchecks() is called every 4 seconds and within that time if its if statement goes true then I want to reset my timer back to 0 but it does not do it. Could someone please point out what is it that I am doing wrong? If so how do I reset my game timer from other different functions outside the update()?

1 decade ago by stillen

I would use timer.reset()
update:function(){
           if (this.timer.delta() >4) {
              this.timer.reset();// sets timer to 0
             fourSecondDelayFunction() // do check that happens every 4 seconds
           }
 },
Page 1 of 1
« first « previous next › last »