本文介绍了C#-检测PictureBox重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以检测到pictureBox是否与另一个pictureBox发生碰撞/重叠?抱歉,问题模棱两可.

Is it possible to detect if a pictureBox is colliding with/overlapping with another pictureBox? Sorry for the vague question formulation.

推荐答案

要检查2个矩形是否重叠,可以使用 IntersectsWith :

To check if 2 rectangles overlapped you can use IntersectsWith:

bool overlapped= pictureBox1.Bounds.IntersectsWith(pictureBox12.Bounds);

要找到相交区域,可以使用 Rectangle.Intersect :

To find the intersection area you can use Rectangle.Intersect:

Rectangle intersectionArea = Rectangle.Intersect(pictureBox1.Bounds, pictureBox2.Bounds);

这篇关于C#-检测PictureBox重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 20:31