WinForm中两个PictureBox之间的碰撞检测

ddf*_*dad -2 c# winforms

我有两个PictureBox正在移动表格.他们可能会碰撞在一起.我如何知道他们是否发生碰撞?

我应该使用他们的位置吗?

ann*_*sly 9

您可以使用该Rectangle.IntersectsWith方法确定它们是否相交.

if (pictureBox1.Bounds.IntersectsWith(pictureBox2.Bounds))
{
    //They have collided
}
Run Code Online (Sandbox Code Playgroud)