0

ドラッグ アンド ドロップ ゲームを作成しました。タイムアウトになったときにすべての mouseEvents を停止する方法はありますか?

以下は、タイマーの私のコードです。

var canvas = document.getElementById("canvas");
var canvas_context = canvas.getContext("2d");
var text = "you have: 10 : 00 left"

function showFillText() {
canvas_context.clearRect(500, 350, 80, 100);
canvas_context.fillStyle = '#36F'; //text color
canvas_context.font = ' bold 20px sans-serif';
canvas_context.textBaseline = 'bottom'; 
canvas_context.fillText(text, 500, 450); //('text', x, y)
}
var mins = .1;  //Set the number of minutes you need
var secs = mins * 60;
var currentSeconds = 0;
var currentMinutes = 0;
setTimeout('Decrement()',1000);

function Decrement() {
    currentMinutes = Math.floor(secs / 60);
    currentSeconds = secs % 60;
    if(currentSeconds <= 9) currentSeconds = "0" + currentSeconds;
    secs--;
   text = currentMinutes + ":" + currentSeconds; //Set the element id you need the time put into.
    if(secs !== -1) setTimeout('Decrement()',1000);
    //document.getElementById("timerText").innerHTML = currentMinutes + ":" + currentSeconds; 
    if (currentMinutes == 0 && currentSeconds ==0)  {
    text = "TIMES UP"   
    //document.location.href = "http://www.google.com";
    }
    showFillText()
}
4

3 に答える 3