本文介绍了C#Picturebox到Picturebox的交互的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮助我吗?我想制作的是这样,如果一个pictuebox碰到另一个picrebox,则将发生某些事情,例如我正在使用
Can anyone please help me? I''m trying to make is so that if a pictuebox hits another picrebox something will happen for example i''m using
if (e.KeyCode == Keys.Up)
{
You.Location = new Point(You.Location.X, You.Location.Y - 5);
}
然后图片框会上升,当它碰到该区域中的另一个图片框时,它会执行某些操作,
我的主意是
and the picturebox will go up and when it hits another picurebox that is in the area it will do something,
my idea was
if(picturebox1.location == picruebox2.location)
{
}
它会做某事,但是它必须要击中一个确切的像素,但这很难,我想要,所以如果您在移动时击中picturebbox,它会做某事,有人可以帮忙吗?
and it will do something, but it will have to hit a exact pixel, but that is very hard, i want it so if you hit the picturebbox while moving it will do something, can anyone help?
推荐答案
movingPictureBox.Top -= 20;
if (stationaryPictureBox.Bounds.Contains(movingPictureBox.Location))
{
MessageBox.Show("Inside");
}
是否更有意义?
这篇关于C#Picturebox到Picturebox的交互的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!