I have a Timer that is being drawn, but not changing at all. It shows 0: 01, and is not adding by the second. This probably has something to do with the setInterval, but i am not sure.
function drawTimer() {
var fontSize = 15;
graph.lineWidth = playerConfig.textBorderSize;
graph.fillStyle = playerConfig.textColor;
graph.strokeStyle = playerConfig.textBorder;
graph.miterLimit = 1;
graph.lineJoin = 'round';
graph.textAlign = 'right';
graph.textBaseline = 'middle';
graph.font = 'bold ' + fontSize + 'px sans-serif';
var gameTimeMinutes = 0;
var gameTimeSeconds = 1;
var gameTime = "";
function addTime() {
gameTimeSeconds += 1;
}
setInterval(addTime, 1000);
if (gameTimeSeconds < 10) {
gameTime = gameTimeMinutes + " : 0" + gameTimeSeconds;
} else {
gameTime = gameTimeMinutes + " : " + gameTimeSeconds;
}
if (gameTimeSeconds == 60) {
gameTimeSeconds = 0;
gameTimeMinutes++;
}
graph.strokeText(gameTime, 50, 50);
graph.fillText(gameTime, 50, 50);
}
Thanks.