第二次在Whack-a-mole中点击“开始游戏”后,“游戏结束”不消失

时间:2018-07-19 05:34:42

标签: javascript jquery html css frontend

我刚刚开始学习jQuery,并制作了Whack-a-mole游戏。游戏运行正常。但是一旦游戏结束,我再次单击开始游戏按钮,游戏就会开始,但“ Game Over”消息仍然存在。

这是我的仓库的链接:https://github.com/kshitiz20/Whack-a-mole

以下是游戏的链接:https://kshitiz20.github.io/Whack-a-mole/

如何解决此错误?

1 个答案:

答案 0 :(得分:2)

这应该为您工作:

function startGame(){
    makeGameBoard();
    score=0;
    $('.score').text(score);
    startMoles();
    gameOver=false;
    $('.message').html(''); <-- clear the html
    setTimeout(function(){
        return gameend();
    },15000);
}