如何知道两个图片框是否在特定边界上发生碰撞。 C#

时间:2016-08-27 09:19:10

标签: c# picturebox

我有两个图片框: pbX pbY

我想知道 pbX右边界何时与 pbY左边界相交。

这是我的代码:

 if (this.pbX.Bounds.IntersectsWith(pbY.Bounds))
            {
                /*Show message*/
            }

我怎么能这样做?

感谢。

1 个答案:

答案 0 :(得分:1)

再使用一次,可能是这样的:

if (pbX.Bounds.IntersectsWith(pbY.Bounds))
{
    if (pbX.Right >= pbY.Left) 
    {
       /*Show message*/
    }
}