admin管理员组文章数量:1244303
I want to stop a timeup counter at the same moment when the game ends. (bomb explodes, all the bombs are found).
The end of my Javascript is here:
//timeup counter
let minutesLabel = document.getElementById("minutes");
let secondsLabel = document.getElementById("seconds");
let totalSeconds = 0;
setInterval(setTime, 1000);
function setTime() {
++totalSeconds;
secondsLabel.innerHTML = pad(totalSeconds % 60);
minutesLabel.innerHTML = pad(parseInt(totalSeconds / 60));
}
function pad(val) {
var valString = val + "";
if (valString.length < 2) {
return "0" + valString;
} else {
return valString;
}
}
//game over
function gameOver(square) {
result.innerHTML = 'BOOM! Game Over!'
isGameOver = true
}
//show ALL the bombs
squares.forEach(square => {
if (square.classList.contains('bomb')) {
square.innerHTML = '
本文标签:
counterHow to end Countup TimerJavascriptStack Overflow
版权声明:本文标题:counter - How to end Countup Timer - Javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人,
转载请联系作者并注明出处:http://www.betaflare.com/web/1740199201a2239891.html,
本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论