Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 231
  • Last Modified:

how to do animation in visual basic ?

how to do animation in visual basic ???
0
nana78
Asked:
nana78
  • 2
1 Solution
 
TrueIdiotCommented:
All depends on what kind of animation you mean. Some thing pretty simple can be done with a few image boxes and a timer. If you want to just have a picture move across the screen just use a timer, and whenever the timer fires just change the left or top coordinates of the object. Of course, you can always just do it like the real animators do, make a picture for each frame or so, use a timer, and load the next picture into your image box, like so:

Note: name all your picture files w/ the same extension and a naming scheme like frame1.jpg for the first frame, frame2.jpg for the second, ect.

Private Const strBasePath as String _
= "C:\WhereThePicturesAre"
Private Const strExt as String = ".jpg" 'assuming jpg files
...
...
...
Private Sub tmrTimer_Interval()
   static intFrame as integer
   tmrTimer.enabled
   

intFrame = intFrame + 1

   imgMyImageBox.Picture = LoadPicture(strBasePath & _
   intFrame & strExt)
End Sub


all you do is set the timer interval
0
 
TrueIdiotCommented:
All depends on what kind of animation you mean. Some thing pretty simple can be done with a few image boxes and a timer. If you want to just have a picture move across the screen just use a timer, and whenever the timer fires just change the left or top coordinates of the object. Of course, you can always just do it like the real animators do, make a picture for each frame or so, use a timer, and load the next picture into your image box, like so:

Note: name all your picture files w/ the same extension and a naming scheme like frame1.jpg for the first frame, frame2.jpg for the second, ect.

Private Const strBasePath as String _
= "C:\WhereThePicturesAre"
Private Const strExt as String = ".jpg" 'assuming jpg files
...
...
...
Private Sub tmrTimer_Interval()
   static intFrame as integer
   tmrTimer.Enabled = False
   
   If intFrame <> TheTotalNumberOfFrames Then
     intFrame = intFrame + 1

     imgMyImageBox.Picture = LoadPicture(strBasePath & _
     intFrame & strExt)
     tmrTimer.Enabled = True
   End If
End Sub


all you do is set the timer interval to something like 10 miliseconds (just play around with it until it looks good) and viola (i think that's how you spell it...)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now