Dim stepy As Integer '纵向移动增量
Dim stepx As Integer '横向移动增量
Const LEFT_BUTTON = 1
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim x0 As Integer, y0 As Integer, a As Single, radius As Integer
radius = Shape1.Width / 2 '圆的半径
If Button = LEFT_BUTTON Then
x0 = Shape1.Left + radius '圆心的x坐标
y0 = Shape1.Top + radius '圆心的y坐标
If x = x0 Then
stepy = Sgn(y - y0) * 50
' stepx = ?
Else
a = (y - y0) / (x - x0) '斜率
stepx = Sgn(x - x0) * 50
' ? = a * stepx
If Abs(stepy) > Abs(stepx) Then
stepy = Sgn(y - y0) * 50
stepx = stepy / a
End If
End If
' ? = True
Else
' ? = False
End If
End Sub
Private Sub Timer1_Timer()
' Shape1.Move Shape1.Left + stepx, Shape1.Top + ?
End Sub
发布于 2022-05-11 10:13:23
登录后免费查看答案
关注者
0
被浏览
26