具有巨大边界的文本框?

TextBox with Huge Bounds?

我做了碰撞检测功能:

private bool collision()
    {
        foreach (Control c in this.Controls)
        {
            if (c.Bounds.IntersectsWith(player.Bounds))
            {
                if(c.Name == "")
                {
                    return false;
                }
                return true;
            }
        }
        return false;
    }

它起作用了,但是,"player" PictureBox(设置为自动调整大小,并且 sprite 的大小是精确的:没有外围透明像素)与 TextBox 发生碰撞,同时仍然离它很远。有办法解决这个问题吗?

从两个控件边界(与父控件相关)推导出屏幕边界,然后计算交集:

 Rectangle BoundsInScreenCoor = 
   new Rectangle(c.PointToScreen(new Point(c.Left,c.Top),new Size(c.Width,c.Height)) ;