求助:关于图片沿固定轨迹移动
各位大侠好:
程序要求图片(小车)能够沿着我所画的直线行走,直线呈现为两个口子型,请各位出个方法,谢谢了!
已知图片(小车)的速度
一、直线轨迹
Private Sub PictureBox3_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox3.Paint
e.Graphics.DrawLine(Pens.Red, 0, 0, CType(sender, PictureBox).Width, CType(sender, PictureBox).Height)
Dim pen2 As New Pen(Color.Yellow, 3)
'pen2.EndCap = Drawing.Drawing2D.LineCap.ArrowAnchor
e.Graphics.DrawLine(pen2, CType(sender, PictureBox).Width - 100, 150, 20, 150)
e.Graphics.DrawLine(pen2, 20, 150, 20, CType(sender, PictureBox).Height - 50)
e.Graphics.DrawLine(pen2, 20, CType(sender, PictureBox).Height - 50, CType(sender, PictureBox).Width - 200, CType(sender, PictureBox).Height - 50)
e.Graphics.DrawLine(pen2, CType(sender, PictureBox).Width - 200, CType(sender, PictureBox).Height - 50, CType(sender, PictureBox).Width - 200, 50)
e.Graphics.DrawLine(pen2, CType(sender, PictureBox).Width - 200, 50, CType(sender, PictureBox).Width - 100, 50)
e.Graphics.DrawLine(pen2, CType(sender, PictureBox).Width - 100, 50, CType(sender, PictureBox).Width - 100, 150)
End Sub
[解决办法]
1.定时刷新,invalide即可;
2.改变小车位置;
3.先绘制路径,在绘制小车即可!