function doKeyDown(event) {
switch (event.keyCode) {
case 32:
/* Space bar was pressed */
if (x == 4) {
setInterval(drawAll, 20);
}
else {
setInterval(drawAll, 20);
x += dx;
}
break;
}
}
Run Code Online (Sandbox Code Playgroud)
大家好,
我想调用drawAll()一次不创建一次又一次调用的循环,drawAll我应该使用递归方法还是应该使用clearInterval?
还请告诉我使用clearInterval?谢谢 :)