I have a timer that starts when the game starts.
I need to figure out how to stop the timer when the game is over and then return the value (time that has elapsed)
Here is the timer I have:
function gameTimer(status) {
$(".notes").text(status);
if (gameStart == true) {
gameStart = false; // so game will not repeat when image is clicked again to start game
var timer = setInterval(calltimer, 1000);
function calltimer() {
$(".timerInner").text(time);
if (status == true) {
time++;
}
}
}
}
Here is how I vision the functions working:
gameTimer(start); // start timer
gameTimer(pause); // pause timer in case user needs to step away
gameTimer(stop); // stop timer and return value
Any ideas on how I would get something like this implemented?
Thanks,