vb 小球弹跳运动,应用timer
原题:让一个红色小球每隔1秒从当前位置向下移动100缇,遇到窗体底部后再向上运动,而遇到窗体顶部有改成向下运动,直到按下命令按钮后停止运动。(需要详细,完整的步骤,寻求高...
原题:让一个红色小球每隔1秒从当前位置向下移动100缇,遇到窗体底部后再向上运动,而遇到窗体顶部有改成向下运动,直到按下命令按钮后停止运动。(需要详细,完整的步骤,寻求高手的完整回答)
展开
2个回答
展开全部
窗体放一个shape控件,Timer控件,按钮控件:
Dim d As Boolean '方向
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If Not d Then
If Shape1.Top < Me.ScaleHeight - Shape1.Height Then
Shape1.Top = Shape1.Top + 100
Else
d = Not d
End If
Else
If Shape1.Top > 100 Then
Shape1.Top = Shape1.Top - 100
Else
d = Not d
End If
End If
End Sub
Dim d As Boolean '方向
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If Not d Then
If Shape1.Top < Me.ScaleHeight - Shape1.Height Then
Shape1.Top = Shape1.Top + 100
Else
d = Not d
End If
Else
If Shape1.Top > 100 Then
Shape1.Top = Shape1.Top - 100
Else
d = Not d
End If
End If
End Sub
11
2024-11-15 广告
2024-11-15 广告
上海允若信息科技有限公司成立于2017年,是一家专注于电磁和等离子体仿真测试解决方案咨询、规划、定制开发和实施推广服务的专业化公司,允若意为:一允千金,上善若水。公司核心团队成员都毕业于国内外著名大学,在世界500强企业有多年工作经验。总部...
点击进入详情页
本回答由11提供
展开全部
窗体放一个shape控件,Timer控件,按钮控件:
Dim d As Boolean '方向
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If Not d Then
If Shape1.Top < Me.ScaleHeight - Shape1.Height Then
Shape1.Top = Shape1.Top + 100
Else
d = Not d
End If
Else
If Shape1.Top > 100 Then
Shape1.Top = Shape1.Top - 100
Else
d = Not d
End If
End If
End Sub
Dim d As Boolean '方向
Private Sub Command1_Click()
Timer1.Enabled = False
End Sub
Private Sub Form_Load()
Shape1.Shape = 3
Shape1.FillColor = vbRed
Shape1.FillStyle = 0
Timer1.Interval = 1000
End Sub
Private Sub Timer1_Timer()
If Not d Then
If Shape1.Top < Me.ScaleHeight - Shape1.Height Then
Shape1.Top = Shape1.Top + 100
Else
d = Not d
End If
Else
If Shape1.Top > 100 Then
Shape1.Top = Shape1.Top - 100
Else
d = Not d
End If
End If
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询