0

可能重复:
文本闪烁 jQuery

当游戏结束时,我正在尝试在我的 HTML5/JavaScript 游戏中创建一个计时器。像 3...2...1.. 会出现 3,然后闪烁,然后 2,然后闪烁,然后 1,然后闪烁并返回到我的标题屏幕......我没有放任何东西可以让它工作。 ..有人能帮我吗?到目前为止,我的数字代码是这样的:

function CreateTimer(){
    timer =  setInterval(function() {
    cntxt.fillText(time, c.width/2 - cntxt.measureText(time).width/2, c.height/4);
    time--;
    }, 1000);

}

function resetTimer(){
clearInterval(timer);
time = 3;
where = "menu";
}

但即使这样也只会将第二个数字和第三个数字直接放在前一个数字上,然后按预期返回标题。

先谢谢了!

4

1 回答 1

0

你需要先清除文本见http://www.w3schools.com/html5/canvas_clearrect.asp

于 2012-09-09T18:40:52.573 回答