iOS,Game模板碰撞检测的一些细节篇一:jQuery+DIV碰撞检测(猫捉老鼠游戏)!--何奕勇-heyiyong-qq-290248126说明:jQuery+DIV碰撞检测(猫捉老鼠游戏)--!DOCTYPEhtmlhtmlheadtitledemo/titlestyletype="text/css"*{padding:0;margin:0;}.mao{background:#ff6e06;position:fixed;width:50px;height:50px;font-size:25px;line-height:50px;text-align:center;z-index:100;}.laoshu{background:#21ff00;position:fixed;top:300px;left:500px;width:100px;height:100px;font-size:25px;text-align:center;line-height:100px;}.result{height:80px;width:300px;background:#ffafb9;color:#219aff;font-weight:bolder;font-size:30px;text-align:center;margin:10pxauto;line-height:80px;}/stylescripttype="text/javascriptsrc="jquery-"/scriptscripttype="text/javascript"varmaoX=0;//水平方向位移varmaoY=0;//垂直方向位移varlaoshuX=500;//水平方向位移varlaoshuY=300;//垂直方向位移/***上下左右移动事件*/$(document).keydown(function(event){if(===37){maoY=maoY-10;$("#mao").css("left",maoY+"px");}elseif(===38){maoX=maoX-10;$("#mao").css("top",maoX+"px");}elseif(===39){maoY=maoY+10;$("#mao").css("left",maoY+"px");}elseif(===40){maoX=maoX+10;$("#mao").css("top",maoX+"px");}});functionpengzhuangCheck(){//得到猫的高度和宽度以及(距离左侧和上端的距离)varmaoOffset=$("#mao").offset();varmaoWidth=parseInt($("#mao").css("width").replace("px",""));varmaoHeight=parseInt($("#mao").css("height").replace("px",""));//得到老鼠的高度和宽度以及(距离左侧和上端的距离)varlaoshuOffset=$("#laoshu").offset();varlaoshuHeight=parseInt($("#laoshu").css("height").replace("px",""));varlaoshuWidth=parseInt($("#laoshu").css("width").replace("px",""));//左侧和上方相交的bool值varleftBool;vartopBool;//处理左侧相交if(){leftBool=--laoshuWidth0;//(&quo
iOS,Game模板碰撞检测的一些细节 来自淘豆网www.taodocs.com转载请标明出处.