//矩形碰撞检测,设矩形的左上顶点是(x, y), 宽w, 高h, 那么只要存在以下情况一定不相交, 否则是相交的
function rectangleCol(x1,y1,w1,h1,x2,y2,w2,h2){
var maxX,maxY,minX,minY;
maxX = x1+w1 >= x2+w2 ? x1+w1 : x2+w2;
maxY = y1+h1 >= y2+h2 ? y1+h1 : y2+h2;
minX = x1 <= x2 ? x1 : x2;
minY = y1 <= y2 ? y1 : y2;
if(maxX - minX <= w1+w2 && maxY - minY <= h1+h2){
return true;
}else{
return false;
}
}
function rectangleCol(x1,y1,w1,h1,x2,y2,w2,h2){
var maxX,maxY,minX,minY;
maxX = x1+w1 >= x2+w2 ? x1+w1 : x2+w2;
maxY = y1+h1 >= y2+h2 ? y1+h1 : y2+h2;
minX = x1 <= x2 ? x1 : x2;
minY = y1 <= y2 ? y1 : y2;
if(maxX - minX <= w1+w2 && maxY - minY <= h1+h2){
return true;
}else{
return false;
}
}