VB 6.0 Animation
Dear friends,
Can anyone help me out? (in some simple language)
I am doing a small project with VB 6.0 for analysis of projectile graphically.
1. The project in simple words, after feeding in the required parameters, calculates the X,Y coordinates and draws the line indicating the trajectory. My problem is that after executing the command (command button), the line is drawn immediately which shows the path of the projectile. Actually i require to view the line being drawn and must be drawn slowly wherein the user can view the line being drawn.
2. I want the projectile's point to be represented by a small icon/symbol and i want it to travel at the end of the line when the line is being drawn.
3. When i click on the projectile symbol, a small log book should be displayed which will indicate the true bearing and range from the firing position.
Regards
Thank you
A Krishnan
# 1 Re: VB 6.0 Animation
There are easy ways and hard ways. The hard way prevents flicker, requires a back buffer to draw to, and a lot of API calls.
The easy way, but may produce some flicker with use of image control
1. Use an ImageControl for your projectile, this way you can react to its click event
2. For each point in the projection draw your next line segment.
3. Move your ImageControl to that next point
Tips:
1. Whatever you are drawing on (Form, Picturebox, etc). Set its AutoRedraw to True
2. Move your ImageControl with its .Move method
3. To animate, use a timer and use a module-level variable for the segment number
-- When timer fires, draw segment, move projectile, increment segment number
4. To show projectile stats...
-- When user clicks on projectile, stop timer if it is running, else restart timer if it is not
-- Or pop up a messagebox with that info, timer won't fire while msgbox is displayed
5. Don't forget to stop your timer when path ends and don't forget to reset your segment number before you start a new path.
Just some ideas.
Edited: If flicker is an issue and if your projectile is a solid graphics object (i.e., not an icon or transparent GIF), you can use a borderless picturebox instead of an imagecontrol and you shouldn't experience flicker.