var oDiv=document.querySelector('#box');
var oImg=document.querySelector('#box1');
var n=1,m=1,s=0;
var timer,timer1;
function clock() {
n++;
if(n==4){
n=1;
}
oImg.style.background='url("gameImg/0'+n+'.png")';
}
timer=setInterval(clock,200);
oDiv.onclick=function () {
clearInterval(timer);
clearInterval(timer1);
timer1=setInterval(function () {
s++;
m++;
if(m==4){
m=1;
}
if(s==3){
s=0;
clearInterval(timer1);
timer=setInterval(clock,200);
}
oImg.style.background='url("gameImg/fight0'+m+'.png")';
},100);
}



网友评论