End Sub
Private Sub cmd_onoff_Click() 开关命令按钮
If toggle = 0 Then
cmd_onoff.Caption = "停止"
toggle = 1
Else
cmd_onoff.Caption = "旋转"
toggle = 0
End If
End Sub
Private Sub Timer1_Timer()
If toggle = 1 Then spin 满足条件,调图切换子程序
End Sub
Private Sub spin()
y = y 1: If y = 17 Then y = 0
picture1.Picture = PictureClip1.
GraphicCell(y) 图切换一帧
End Sub
在上面的程序中,使用了命令按钮、图片控件、定时器和图像剪切控件等功能,其中最主要的是制作图像文件。图像文件制作分两个过程,首先制作单个的图像文件,然后,将这些图像文件合并成一个图像文件,存于一个.bmp文件中,在图像合成时可使用WINDOWS/95中的“画图”,用粘贴的方法完成。注意,在图像合成时,应设置状态栏参数以确定图像的精确位置,否则,在动画过程中,图像会出现跳动和不稳定感。
四、使用Image实现动画效果
该功能用定时器控件来控制移动和地球转动的速度,当然,其速度还与程序中设定的步长有关系,具体程序片段如下:
Private Sub Form_Load()
Timer_animate.inteval=100 INTEVAL属性为100ms
Timer_animate.enabled=true 启动动画定时器
End Sub
Private Sub Timer_animate_Timer()
Call ani_Image 定时调移动子程序
End Sub
Sub IncrFrame()
FrameNum = FrameNum 1 帧加1
If FrameNum > 5 Then
最后一帧图像显示之后返回第一帧
FrameNum = 1
End If
Imageearth(0).Picture = Imageearth(FrameNum).Picture
将该帧图像赋给运动的Imageearth(0)控件的Picture属性
End Sub
Sub ani_Image() 控制移动子程序
Select Case Motion 控制移动方向的变量
Case 1 向上和向左移动,步长50 twips
Imageearth(0).Move Imageearth(0).
Left - 50, Imageearth(0).Top - 50
IncrFrame 切换到下一幅图
If Imageearth(0).Left < = 0 Then 向左移动到了边界
Motion = 2 向上和向右移动
ElseIf Imageearth(0).Top < = 0 Then
Motion = 4 向上移动到了边界,改向下和向左移动
End If
Case 2 向右和向上
Imageearth(0).Move Imageearth(0).Left 50,
Imageearth(0).Top - 50
IncrFrame
到了右边界,转为向左和向上
If Imageearth(0).Left >= (startform.Width
- Imageearth(0).Width) Then
Motion = 1
ElseIf Imageearth(0).Top < = 0 Then
Motion = 3 向右向下
End If
Case 3 向右向下
Imageearth(0).Move Imageearth(0).Left 50,
Imageearth(0).Top 50
IncrFrame
If Imageearth(0).Left >= (startform.Width
- Imageearth(0).Width) Then
Motion = 4 向左向下
ElseIf Imageearth(0).Top >=
(startform.Height - Imageearth(0).Height) - 680 Then
Motion = 2 向右向上,其中680 twips是标题和菜单的高度
End If
Case 4 向左向下
Imageearth(0).Move Imageearth(0).Left - 50,
Imageearth(0).Top 50
IncrFrame
If Imageearth(0).Left < = 0 Then
是否到了左边界,如到了转向右向下
Motion = 3
是否到了下边界
ElseIf Imageearth(0).Top >= (startform.Height
- Imageearth(0).Height) - 680 Then
Motion = 1 向左向上
End If
End Select
End Sub
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!




