我正在創建倒數計時器。如果秒數等於零,我已將2 secs
設置爲var seconds
。請幫忙。我需要從獲得2秒遊戲計時器Javascript
var isWaiting = false;
var isRunning = false;
var seconds = 10;
function GameTimer(){
var minutes = Math.round((seconds - 30)/60);
var remainingSeconds = seconds % 60;
if(remainingSeconds < 10){
remainingSeconds = "0" + remainingSeconds;
}
document.getElementById('waiting_time').innerHTML = minutes + ":" + remainingSeconds;
if(seconds == 0){
isRunning = true;
seconds += 2; //I need to stop the program from looping after getting the 2 seconds
}else{
isWaiting = true;
seconds--;
}
}
var countdownTimer = setInterval(GameTimer(),1000);
我想你至少應該告訴人們什麼是你的代碼錯誤?你有什麼問題嗎? –
Hi @charinten。感謝您的答覆。我更新了這個問題。 – rrr