基本上我有一个矩形网格,每个 75x75,并排。我将一个对象放入这些矩形中,当我放置对象时,我需要找出它与 MOST 相交的矩形。
它很可能看起来像这样:
private Rectangle placeObject(Vector2 cursorPosition)
{
Rectangle HolderRectangle;
Rectangle r1 = new Rectangle((int)cursorPosition.Position.X, (int)cursorPosition.Position.Y, 70, 70);
Foreach( Rectangle r in rectangles)
{
r2 = new Rectangle((int)r.Position.X, (int)r.Position.Y, 75,75)
if( r1.Intersects(r2))
{
//Check how much it intersects
//if it intersects more than the current holder Rectangle
//set HolderRectangle = r2
}
}
return HolderRectangle;
}
我要问的甚至可能吗?如果有怎么办?感谢所有回复=)