' Dimension Some Variables
Dim Frame As Integer Dim SpriteX Private Sub Command1_Click() ' Start Animation Timer Timer1.Enabled = True End Sub Private Sub Form_Load() ' Set some initial Variables SpriteX = 0 Frame = 1 End Sub Private Sub Timer1_Timer() If Frame <= 13 Then ' Clear Our Drawing Surface Picture1.Cls ' Extract the image from the imagelist control and draw it on our Drawing Surface ImageList1.ListImages(Frame).Draw Picture1.hDC, SpriteX * 200, , 1 ' Increment the frame we are on Frame = Frame + 1 ' Increment our sprites x co-ordinate SpriteX = SpriteX + 1 ' If our sprite is out of viewing area reset it so it continually runs by If SpriteX = 50 Then SpriteX = 0 ' If we are on the final frame of our animation reset it to the first frame ' this gives us our animation Loop If Frame = 13 Then Frame = 1 End If End Sub ' Dimension Some Variables Dim Frame As Integer Dim SpriteX Private Sub Command1_Click() ' Start Animation Timer Timer1.Enabled = True End Sub Private Sub Form_Load() ' Set some initial Variables SpriteX = 0 Frame = 1 End Sub Private Sub Timer1_Timer() If Frame <= 13 Then ' Clear Our Drawing Surface Picture1.Cls ' Extract the image from the imagelist control and draw it on our Drawing Surface ImageList1.ListImages(Frame).Draw Picture1.hDC, SpriteX * 200, , 1 ' Increment the frame we are on Frame = Frame + 1 ' Increment our sprites x co-ordinate SpriteX = SpriteX + 1 ' If our sprite is out of viewing area reset it so it continually runs by If SpriteX = 50 Then SpriteX = 0 ' If we are on the final frame of our animation reset it to the first frame ' this gives us our animation Loop If Frame = 13 Then Frame = 1 End If End Sub |