(一)动画设计
1)需要:2个button,1个statuscrips,1个imagelist,1个timer
2)设计界面:

3)步骤:
1、添加动画图片到Imagelist中
2、实现从ImageList中读取图片到picturebox,由于动画是通过一系列连贯动作的图片连续快速播放实现,所以读取图片的实现应该写在计时器的Tick事||件中:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox1.Image = ImageList1.Images(x)
x = x + 1
If x >= ImageList1.Images.Count Then
x = 0 ‘如果顺序播放结束则从头开始
End If
End Sub
变量X是从0开始的图片编号,因此需要在开始部分予以定义:
Dim x As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True ‘启动计时器
Timer1.Interval = 100 ‘定义0.1s切换一张图片
x = 0 ‘定义X从第一张开始
End Sub
加速按钮事||件代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = Timer1.Interval – 20
If Timer1.Interval < 100 Then
ToolStripStatusLabel1.Text = "太快了把我累死了!"
End If
If Timer1.Interval = 100 Then
ToolStripStatusLabel1.Text = ""
ToolStripStatusLabel1.Text = "太快了把我累死了!"
End If
If Timer1.Interval <= 20 Then
Button1.Enabled = False
End If
End Sub
减速按钮事||件代码:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button1.Enabled = True
Timer1.Interval = Timer1.Interval + 20
If Timer1.Interval > 100 Then
ToolStripStatusLabel1.Text = "太慢了保持不住啦!"
End If
If Timer1.Interval = 100 Then
ToolStripStatusLabel1.Text = ""
ToolStripStatusLabel1.Text = "太慢了保持不住啦!"
End If
End Sub
1)需要:2个button,1个statuscrips,1个imagelist,1个timer
2)设计界面:

3)步骤:
1、添加动画图片到Imagelist中
2、实现从ImageList中读取图片到picturebox,由于动画是通过一系列连贯动作的图片连续快速播放实现,所以读取图片的实现应该写在计时器的Tick事||件中:
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
PictureBox1.Image = ImageList1.Images(x)
x = x + 1
If x >= ImageList1.Images.Count Then
x = 0 ‘如果顺序播放结束则从头开始
End If
End Sub
变量X是从0开始的图片编号,因此需要在开始部分予以定义:
Dim x As Integer
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Timer1.Enabled = True ‘启动计时器
Timer1.Interval = 100 ‘定义0.1s切换一张图片
x = 0 ‘定义X从第一张开始
End Sub
加速按钮事||件代码:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Timer1.Interval = Timer1.Interval – 20
If Timer1.Interval < 100 Then
ToolStripStatusLabel1.Text = "太快了把我累死了!"
End If
If Timer1.Interval = 100 Then
ToolStripStatusLabel1.Text = ""
ToolStripStatusLabel1.Text = "太快了把我累死了!"
End If
If Timer1.Interval <= 20 Then
Button1.Enabled = False
End If
End Sub
减速按钮事||件代码:
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Button1.Enabled = True
Timer1.Interval = Timer1.Interval + 20
If Timer1.Interval > 100 Then
ToolStripStatusLabel1.Text = "太慢了保持不住啦!"
End If
If Timer1.Interval = 100 Then
ToolStripStatusLabel1.Text = ""
ToolStripStatusLabel1.Text = "太慢了保持不住啦!"
End If
End Sub