var GameBarScript = pc.createScript('gameBarScript');
GameBarScript.attributes.add('timerTxt', {type: 'entity'});
var minutes=0;
var sec=0;
var counter=0;
GameBarScript.prototype.initialize = function() {
this.GameBarScript = 0;
minutes = 0;
sec = 0;
time = setInterval(this.timeIt.bind(this), 1000);
this.timerTxt.element.text = minutes + ":" + sec;
};
GameBarScript.prototype.timeIt = function() {
sec = this.GameBarScript++;
if(sec>59){
minutes++;
this.GameBarScript = 0;
}
this.timerTxt.element.text = minutes + ":" + sec;
};
This is the code I used for my timer. It only shows 0:0 for timerTxt instead of 00:00. And when it counts, it goes from 0:59 to 2:60 instead of 1:00. How do I fix this? I’m only a beginner and I’ve checked all forums so linking me to another forum won’t be of any help.