Moving (Or Animating) Shapes across the screen???

01-16-2005, 07:01 AM
I need to make a shape move from one position on the screen to another the click of a button. And I mean actually move, not just disappear from the first position and then re-appear in the new position within a split second.......It already does that and it looks ****, so I need actual "movement".

Now I know it's possible, but i've searched all over the net AND on msdn, but I can't find anything (plus I don't exactly know what I'm looking for.....word for it's hard to search for it)

Does anyone know how to do this???

01-16-2005, 08:17 AM
the way i use, is to use timers - but there are probably better ways of doing this, but this is the best way i know:

Private Sub Timer1_Timer()
If Image1.Left = 4560 Then 'final position
Timer1.Enabled = True 'stop movement when picture is at correct place
Image1.Left = Image1.Left + 420 'Movement by interval
End If
End Sub

Basically, this code moves the image 420 "places" whether this be twips or pixels etc.

you need to make sure that the distance between start and finish places is divisible by the movement interval (240)

As i said, there are probably better ways of doing this, as someone better at VB than me will point out.

01-16-2005, 02:51 PM
Private Sub Form_Load()
Timer3.Enabled = True
Timer2.Enabled = False
Timer4.Enabled = False
End Sub

Private Sub Timer2_Timer()
Picture1.Top = Picture1.Top + 100
If Picture1.Top = 2500 Then
Timer4.Enabled = True
Timer2.Enabled = False
End If
End Sub

Private Sub Timer3_Timer()
Picture1.Top = Picture1.Top - 100
If Picture1.Top = -2100 Then
Timer3.Enabled = False
Timer2.Enabled = True
End If
End Sub

Private Sub Timer4_Timer()
Picture1.Top = Picture1.Top - 100

01-17-2005, 05:46 AM
err.........wouldn't that be VERY cpu demanding?

01-17-2005, 05:48 AM
yes, but not for very long. If you complement the above with DoEvents it'll look a bit smoother, and the PC will not seem to hang.

01-17-2005, 09:33 AM
well I dout my PC would hang with something like this..........but my point still stands for low-spec PCs

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum