C#中的2个图片框在汽车形状中发生事故 [英] accident of 2 picturebox in car shape in C#
本文介绍了C#中的2个图片框在汽车形状中发生事故的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
你好
我有两个图片框,它们的形状是汽车,我可以通过键盘和鼠标来控制它们.我希望当一辆汽车靠近另一点时,当两车祸发生时,一点可以接收到.实际上,谢谢你
hello
I have two picturebox in my form that their shape is car and I can control their by keyboard ans mouse I want that when one of cars is near other one point can receive actually when 2 car accident one point can receive thank you very much
推荐答案
如果您谈论的是碰撞检测,那么它可能会非常复杂.但是,由于您使用的是图片框(矩形),因此您的代码可以简单得多:
If you are talking about collision detection, then it can be quite complex. However, since you are using pictureboxes (which are rectangles) your code can be a lot simpler:
PictureBox myCar = new PictureBox();
PictureBox yourCar = new PictureBox();
...
if (myCar.Bounds.IntersectsWith(yourCar.Bounds))
{
// Bang!
}
这篇关于C#中的2个图片框在汽车形状中发生事故的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文