我刚开始学习 jQuery 并制作了一个打地鼠游戏。游戏运行良好。但是一旦游戏结束,我再次点击开始游戏按钮,游戏开始了,但“游戏结束”消息仍然存在。
这是我的存储库的链接:https://github.com/kshitiz20/Whack-a-mole
这是游戏的链接:https://kshitiz20.github.io/Whack-a-mole/
我该如何修复这个错误?
最佳答案
这应该适合你:
function startGame(){
makeGameBoard();
score=0;
$('.score').text(score);
startMoles();
gameOver=false;
$('.message').html(''); <-- clear the html
setTimeout(function(){
return gameend();
},15000);
}
关于javascript - 在 Whack-a-mole 中第二次单击 "Game Over"后 "Start game"没有消失,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51415022/