在VB中如何使小球按照一定的轨迹运动

来源:百度知道 编辑:UC知道 时间:2024/06/20 07:03:14
在Visual Basic中如何使小球或者是其他的物体按照规定的直线、折线、曲线运动。

直线往复移动需要两个command,一个timer,一个lable控件timer的interval属性为1或自定义。折线和曲线需要自己定义方程式。

Dim Step As Integer
Private Sub Command1_Click()
Timer1.Enabled = True
End Sub

Private Sub Command2_Click()
Timer1.Enabled = flase
Timer1_Timer ' .改成_
End Sub

Private Sub Form_Load()
Step = 1
End Sub

Private Sub Timer1_Timer()
Label1.Move Label1.Left + 50 * Step
If Label1.Left + Label1.Width > Form1.Width Then
Step = -1
ElseIf Label1.Left < 0 Then '改成小于零
Step = 1
End If
End Sub