如何检查一个矩形是否与另一个矩形相交。
答案 0 :(得分:4)
查看API:http://docs.oracle.com/javase/6/docs/api/java/awt/Rectangle.html
有一个交叉方法:
public boolean intersects(Rectangle r);
例如:
if (player.intersects(object)) {
// player and object are overlapping, do something here...
}