首先,我知道已经回答了非常相似的问题,但我还没有看到这个问题特别被问到。
我有一个椭圆和一个矩形,我想检测它们是否相交。我知道你可以用两个矩形来做到这一点:
if (new Rectangle(x1, y1, w1, h1).intersects(new Rectangle(x2, y2, w2, h2))) {
//code here for when collision occurs.
}
像这样的椭圆形可以做到这一点吗?
if (new Oval(x1, y1, w1, h1).intersects(new Rectangle(x2, y2, w2, h2))) {
//code here for when collision occurs.
}
提前致谢!