/** * 较为通用的矩形碰撞检测方法 * @param ax a矩形左上角x坐标 * @param ay a矩形左上角y坐标 * @param aw a矩形宽度 * @param ah a矩形高度 * @param bx b矩形左上角x坐标 * @param by b矩形左上角y坐标 * @param bw b矩形宽度 * @param bh b矩形高度 * @return */ public static final boolean isIntersectingRect(int ax, int ay, int aw, int ah, int bx, int by, int bw, int bh) { if (by + bh < ay // is the bottom of b above the top of a? by > ay + ah // is the top of b below bottom of a? bx + bw < ax // is the right of b to the left of a? bx > ax + aw) // is the left of b to the right of a? return false;