vb 根据圆的轨迹运动,vb高手进
vb先画一个圆,再让一个控件或图片根据圆的轨迹圆周重复运动,或者只要给我个根据轨迹圆运动的代码...
vb 先画一个圆,再让一个控件或图片根据圆的轨迹圆周重复运动,或者只要给我个根据轨迹圆运动的代码
展开
2个回答
2013-09-23
展开全部
Dim pi As Double
Dim runTime As Double
Dim a As Single, b As Single
Dim cntX As Single, cntY As Single
Dim r As Single
Private WithEvents Timer1 As Timer
Dim tX As Single, tY As Single
Dim tStep As SinglePrivate Sub Form_Load()
Me.ScaleMode = 3
Me.AutoRedraw = True
pi = Atn(1)
Set Timer1 = Controls.Add("vb.timer", "Timer1")a = 50 '椭圆长轴
b = 50 '椭圆短轴
cntX = 100 '中心坐标X
cntY = 60 '中心坐标Y
r = 10 '圆半径
Timer1.Interval = 50 '运动间隔(毫秒)
tStep = pi / 10 '角度步长Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
runTime = runTime + 1
Dim Arg As Double
Arg = runTime * tStep
tX = cntX + a * Cos(Arg)
tY = cntY + b * Sin(Arg)
Me.Cls
Me.DrawStyle = 2
Me.Circle (cntX, cntY), a, , , , b / a
Me.DrawStyle = 0
Me.Circle (tX, tY), r
End Sub
Dim runTime As Double
Dim a As Single, b As Single
Dim cntX As Single, cntY As Single
Dim r As Single
Private WithEvents Timer1 As Timer
Dim tX As Single, tY As Single
Dim tStep As SinglePrivate Sub Form_Load()
Me.ScaleMode = 3
Me.AutoRedraw = True
pi = Atn(1)
Set Timer1 = Controls.Add("vb.timer", "Timer1")a = 50 '椭圆长轴
b = 50 '椭圆短轴
cntX = 100 '中心坐标X
cntY = 60 '中心坐标Y
r = 10 '圆半径
Timer1.Interval = 50 '运动间隔(毫秒)
tStep = pi / 10 '角度步长Timer1.Enabled = True
End SubPrivate Sub Timer1_Timer()
runTime = runTime + 1
Dim Arg As Double
Arg = runTime * tStep
tX = cntX + a * Cos(Arg)
tY = cntY + b * Sin(Arg)
Me.Cls
Me.DrawStyle = 2
Me.Circle (cntX, cntY), a, , , , b / a
Me.DrawStyle = 0
Me.Circle (tX, tY), r
End Sub
2013-09-23
展开全部
如果是动画需要可以用flash实现,需要的话,加我
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询