if 左 then
' 向左运动
x1=x1+1
end if
if 右 then
' 向右运动
x1=x1-1
end if
if 上 then
' 向上运动
y1=y1+1 ' 使用自定义 坐标系统 有统一的坐标转换过程
end if
if 下 then
' 向下运动
y1=y1-1
end if
''达到最大边界后判断处理过程,回原始位置再来 还是 向反方向走
''
Private Sub Command2_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Timer1.Enabled = False
End Sub
Private Sub Timer1_Timer()
If Option1.Value = True Then
Shape1.Top = Shape1.Top - 5
If Shape1.Top = 0 Then Option2.Value = True
End If
If Option2.Value = True Then
Shape1.Top = Shape1.Top + 5
If Shape1.Top = Picture1.Height - Shape1.Height Then Option1.Value = True
End If
If Option3.Value = True Then
Shape1.Left = Shape1.Left - 5
If Shape1.Left = 0 Then Option4.Value = True
End If
If Option4.Value = True Then
Shape1.Left = Shape1.Left + 5
If Shape1.Left = Picture1.Width - Shape1.Width Then Option3.Value = True
End If
End Sub
_________________________
option1~4分别是上下左右,注意设置timer1属性的interval
满意的话请采纳哦~
单选按钮不能直接控制运动方向,这个思路要转换过来,动画动画,就是动一下画一下,要用timer控件改变图片框的坐标,单选按钮只能控制timer控件的启动和终止