增加延迟在JavaScript中如何添加延迟到JavaScript的循环 在这下面的代码在JavaScript中如何循环
snakeclass.prototype.start = function() {
while(1){
if(this.collision()){
console.log("game over");
break;
}
this.movesnake();
// delay here by 300 miliseconds
}
};
我怎样才能在这里使用设置超时功能;
你的意思是延迟整个while循环吗? – Shawn31313
@ Shawn31313 yess – qwerty
http://stackoverflow.com/questions/24849/is-there-some-way-to-introduce-a-delay-in-javascript – 2013-07-14 22:06:19