VB编程:鼠标跟随游戏中光点移动而移动的原码如何写?
1个回答
展开全部
Private Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
Dim x As Single, y As Single, l As Single, t As Single
Private Sub Form_Load()
Randomize
Timer1.Interval = 1000
With Shape1
.Height = 135
.Width = 135
.Shape = 3 'circle
.FillStyle = 0 'solid
End With
End Sub
Private Sub Timer1_Timer()
a = 14
x = Me.Width * Rnd
y = Me.Height * Rnd
l = Me.Left / a
t = Me.Top / a
Shape1.Left = x
Shape1.Height = y
SetCursorPos x / a + l, y / a + t
End Sub
Dim x As Single, y As Single, l As Single, t As Single
Private Sub Form_Load()
Randomize
Timer1.Interval = 1000
With Shape1
.Height = 135
.Width = 135
.Shape = 3 'circle
.FillStyle = 0 'solid
End With
End Sub
Private Sub Timer1_Timer()
a = 14
x = Me.Width * Rnd
y = Me.Height * Rnd
l = Me.Left / a
t = Me.Top / a
Shape1.Left = x
Shape1.Height = y
SetCursorPos x / a + l, y / a + t
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询