///下面给出的代码是我使用setTimeout()的循环功能
if(gameLevel==1){
x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 3000);
}else if(gameLevel==2){
x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 2500);
}
else if(gameLevel==3){
x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 2000);
}
else if(gameLevel==4){
x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 1500);
}
else if(gameLevel==5){
x=setTimeout(function(){gameEngine(radioValue,height,width,gameLevel)}, 1000);
}
///我想在变量playerLife <1时停止此setTimeout(),我使用了如下所示的clearTimeout(),但是它不起作用,请帮忙,谢谢!!
if(playerLife<1)
{
console.log(playerLife);
clearTimeout(x);
}