问题描述
intx1=pictureBox2.Location.X;inty1=pictureBox2.Location.Y;intindex=0;if(e.KeyCode==Keys.Up)index=1;if(e.KeyCode==Keys.Down)index=2;if(e.KeyCode==Keys.Left)index=3;if(e.KeyCode==Keys.Right)index=4;switch(index){case1:intx2=pictureBox4.Location.X;inty2=pictureBox4.Location.Y;if(x1==x2&&y1-y2==37){pictureBox2.Top-=40;pictureBox4.Top-=40;}elsepictureBox2.Top-=40;pictureBox2.Location=break;case2:intx4=pictureBox6.Location.X;inty4=pictureBox6.Location.Y;if(x1==x4&&y4-y1==37){pictureBox2.Top+=40;pictureBox6.Top+=40;}elsepictureBox2.Top+=40;break;case3:intx6=pictureBox3.Location.X;inty6=pictureBox2.Location.Y;if(y1==y6&&x1-x6==36){pictureBox3.Left-=40;pictureBox2.Left-=40;}elsepictureBox2.Left-=40;break;case4:intx8=pictureBox5.Location.X;inty8=pictureBox5.Location.Y;if(y1==y8&&x8-x1==37){pictureBox2.Left+=40;pictureBox5.Left+=40;}elsepictureBox2.Left+=40;break;}代码如上,想实现人动,箱子也动。但运行时,只有当开始时人的位置在哪个箱子旁边,那个箱子才能动,否则箱子就不能动。小弟是新手,那位大哥帮帮忙!!!!!
解决方案
解决方案二:
人和箱子改變位置后,相應人的坐標要跟著變.
解决方案三:
說明你程序中人的位置坐標沒有及時更新.
解决方案四:
现在想实现游戏重新开始。pictureBox2.Location()=newPoint(197,164);即把控件位置移到原来位置,但提示:不能以方法的方式使用不可调用的“system.Windows.Forms.Control.Location”怎么办呢???
解决方案五:
pictureBox2.Location=newPoint(197,164);
解决方案六:
这解决了,但游戏重新开始还是不会做啊。跪求教下!!!!!!!能否留个联系方式,慢慢询问呢。