首页 > 解决方案 > "Game Over" not disappearing after clicking for second time on "Start game" in Whack-a-mole

问题描述

I just started learning jQuery and have made a Whack-a-mole game. The game is working just fine. But once the game gets over and I click the start game button again, the game starts but "Game Over" message is still there.

Here is the link to my repo: https://github.com/kshitiz20/Whack-a-mole

Here is the link to the game: https://kshitiz20.github.io/Whack-a-mole/

How do i fix this bug?

标签: javascriptjqueryhtmlcssfrontend

解决方案


这应该为你工作:

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

推荐阅读