欢迎来到天天文库
浏览记录
ID:42684680
大小:15.05 KB
页数:8页
时间:2019-09-20
《连连看小程序》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、varwidth=11;varheight=10;varlinkStack=null;varlock=false;varnumbers=42;vartimeCount=90;varenableTimer=true;vartimer=null;varlose=false;functioncreateCanvas(_width,_height){for(vari=2;i<_width-2;i++){for(varj=2;j<_height-2;j++){varsquareId="ele"+(i-1)+"_"+
2、(j-1);varsquareObj=document.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+points[i][j].value+".png)";squareObj.onclick=eleChoose;}}}functioneleChoose(_event){if(lose)return;if(lock)return;lock=true;varevent;varp;varpath;if(window.eve
3、nt){event=window.event;p=getPoint(event.srcElement.getAttribute("id"));}else{event=_event;p=getPoint(event.target.getAttribute("id"));}if(linkStack.length==0){choose(p);linkStack.push(p);}else{if(p.x==linkStack[0].x&&p.y==linkStack[0].y){unchoose(linkStac
4、k.pop());lock=false;return;}choose(p);if(p.value==linkStack[0].value){path=linkPoints(linkStack[0],p);if(path){for(vari=0;i5、6、path[i].x>87、8、path[i].y<29、10、path[i].y>7){unchoose(linkStack.pop());linkStack.push(p);lock=false;retu11、rn;}}unchoose(linkStack.pop());unchoose(p);linkSus(path);}else{path=linkPoints(p,linkStack[0]);if(path){for(vari=0;i12、13、path[i].x>814、15、path[i].y<216、17、path[i].y>7){unchoose(linkStack.pop());linkStack.push(p);lock=false;return;}}un18、choose(linkStack.pop());unchoose(p);linkSus(path);}else{unchoose(linkStack.pop());linkStack.push(p);}}}else{unchoose(linkStack.pop());linkStack.push(p);}}lock=false;}functionchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=docum19、ent.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+"-2.png)";//setTimeout(unchoose,200,_point);//setTimeout(blink,300,_point);}functionunchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document20、.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+".png)";}functionblink(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document.getElementById(squareId);squareO
5、
6、path[i].x>8
7、
8、path[i].y<2
9、
10、path[i].y>7){unchoose(linkStack.pop());linkStack.push(p);lock=false;retu
11、rn;}}unchoose(linkStack.pop());unchoose(p);linkSus(path);}else{path=linkPoints(p,linkStack[0]);if(path){for(vari=0;i12、13、path[i].x>814、15、path[i].y<216、17、path[i].y>7){unchoose(linkStack.pop());linkStack.push(p);lock=false;return;}}un18、choose(linkStack.pop());unchoose(p);linkSus(path);}else{unchoose(linkStack.pop());linkStack.push(p);}}}else{unchoose(linkStack.pop());linkStack.push(p);}}lock=false;}functionchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=docum19、ent.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+"-2.png)";//setTimeout(unchoose,200,_point);//setTimeout(blink,300,_point);}functionunchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document20、.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+".png)";}functionblink(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document.getElementById(squareId);squareO
12、
13、path[i].x>8
14、
15、path[i].y<2
16、
17、path[i].y>7){unchoose(linkStack.pop());linkStack.push(p);lock=false;return;}}un
18、choose(linkStack.pop());unchoose(p);linkSus(path);}else{unchoose(linkStack.pop());linkStack.push(p);}}}else{unchoose(linkStack.pop());linkStack.push(p);}}lock=false;}functionchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=docum
19、ent.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+"-2.png)";//setTimeout(unchoose,200,_point);//setTimeout(blink,300,_point);}functionunchoose(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document
20、.getElementById(squareId);squareObj.style.backgroundImage="url(img/"+_point.value+".png)";}functionblink(_point){varsquareId="ele"+(_point.x-1)+"_"+(_point.y-1);varsquareObj=document.getElementById(squareId);squareO
此文档下载收益归作者所有