Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simple animation with vb6 2

Status
Not open for further replies.

Jooky68

Programmer
Jul 10, 2002
231
US
I am interested in making simple animations with vb, nothing complex at all just looping thoruhg images so it looks like an animation or moving around an image, etc. I know this is a very vague post but can anyone maybe point me to a good website that has some useful information, or can anyone give me any pointers ??
Thanks in advance

Paul J
 
Hey,

is usually a good start.

To loop an image, you can create an array of images in a file, e.g image1, image2, image3,image4 etc then on a form create an imagebox and a timer, and on each call of the timer load a different image I can't remember the syntax (i produced a virtual slot machine which did a similar thing) but pseudo-code wise it is something like...


'For 5 images

Private sub Timer1()
If ImageCount = 6 then ImageCount = 1
End If
Set ImgBox.Picture = "PathOfPicture" & ImageCount
ImageCount = ImageCount + 1
End Sub

All the code apart from the set picture is correct, but the idea is right This will then loop an image box through 5 images stored in a folder.

When I find the correct load image code I'll post it.

Hope this helps

Sam
 
Could you not just create an animated gif of the images and then just display the gif on the form? There was a nice solution for showing gif's by vb5prgrmr (thread222-568832) although there were a few problems with transparency.

----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Hey, looking at the thread ca8msm posted the set picture code would be.

Set ImageBox = LoadPicture("Pathname" & ImageCount)

ImageBox is the name of your image box or picture box.
Alternatively you could do what ca8msm said probably more efficient.

Hope this helps

Sam
 
spankyou, the method that you have posted. Will that run continuously? If not how would i make something run constantly, and also if that method does this, how would i make something not run constantly. Also I dont have any clue how to make an animated gif. Sorry I'm way out of the loop when dealing with any type of graphics. Thanks a lot guys.
 
Jooky - creating a gif is relatively straight forward. I use Paint Shop Pro or Adobe Photoshop. Both of these come with gif animators and simple walkthroughs.

I think these both be downloaded as trial versions so this may be an option for you.



----------------------------------------------------------------------

Need help finding an answer?

Try the search facilty ( or read FAQ222-2244 on how to get better results.
 
Hey Jooky,

The code I have given you will run continuously, to stop that you shout put a counter in the timer. Dim the counter in the form and each time that the timer runs implement it by 1, then you need an if statemnt to stop the timer e.g...

I have called my counter MyCount

Private sub Timer1()
If MyCount = 11 Then
Timer1.Enabled = false
Exit Sub
Else
If ImageCount = 6 then ImageCount = 1
End If
Set ImageBox = LoadPicture("Pathname" & ImageCount)
ImageCount = ImageCount + 1
End If
MyCount = MyCount +1
End Sub

Declare MyCount in the form load sequence. Visual Basic automatically sets a variables value to 0, so using the code above the animation will run 10 times over and then stop.

Hope this helps

Sam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top