【发布时间】:2013-04-06 09:54:35
【问题描述】:
我正在使用 LibGDX 制作游戏,但遇到了有关矩形碰撞检测的问题。
public class Rectangle{
final float width = 1f;
final float height = 0.5f;
Point topLeft;
Point topRight;
Point bottomRight;
Point bottomLeft;
//The point of rotation is the middle of the rectangle
float angle;
}
public class Point{
float x;
float y;
}
使用这些信息(所有这些变量都将被预先计算),我想计算两个矩形是否完全重叠?
【问题讨论】:
-
“但我不确定如何继续检测它们的碰撞,到目前为止我搜索的内容非常复杂。” 还有..什么是你的问题?如果是“如何进行简单的旋转矩形碰撞?”,请注意。答案是“雇人”。
-
“简单”的方法可能是检查
Rectangle2D.contains(x,y)中的每一对代表另一个矩形的角的 4 个 x,y 对。 -
我不相信 Rectangle 类有办法让矩形变角。
-
如需尽快获得更好的帮助,请发帖SSCCE。
-
编辑了我的帖子,希望它能清除一些东西。
标签: java awt collision-detection java-2d rectangles