For Programmers: Free Programming Magazines  


Home > Archive > Visual Basic > November 2005 > animation Effects









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author animation Effects
jack

2005-11-28, 3:55 am

Hi all ,,
just curious for about the animation effect about vb


As i was playing card game i have noticed the animation of the game ..
I have tryed a lot to create an smoot animation effect like this one
but unable to do so

Please do reply me for this

Thanks for Replying

Mike Williams

2005-11-28, 6:55 pm

"jack" <gautams.mail@gmail.com> wrote in message
news:1133161436.431998.101320@g47g2000cwa.googlegroups.com...

> Hi all just curious for about the animation effect about vb
> As i was playing card game i have noticed the animation
> of the game. I have tryed a lot to create an smoot animation
> effect like this one but unable to do so


Depends what sort of animation you want and also on how much you already
know about VB programming and how much work you are prepared to put in. If
you just want something simple like dragging a rectangular "playing card" or
something around the screen the code is quite simple. Basically you simply
adjust the x and y coordinates of a suitable control (a picture box for
example) according to the user's movements of the mouse and the operating
system will do the rest for you. If however you mean more complex animation
then the best way is to draw your background and all your "moving images"
(at their current position) into a hidden bitmap and then dump that bitmap
to the display (you need to repeat this every time something on the screen
is required to move from one position to the next). It can be very simple
or very complex, depending on exactly what you want to do. Here for example
is a simple way of allowing the user to drag a picture box around a Form.
Paste the code into a VB Form containing one picture box. Note that that are
other ways to do this job, just as there are numerous ways of doing almost
every job in VB.

Mike

Option Explicit
Private dragging As Boolean
Private xmouse As Single, ymouse As Single

Private Sub Form_Load()
Picture1.ScaleMode = Me.ScaleMode
End Sub

Private Sub Picture1_MouseDown(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
xmouse = X
ymouse = Y
dragging = True
End Sub

Private Sub Picture1_MouseMove(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
Dim x1 As Single, y1 As Single
If dragging Then
x1 = Picture1.Left + X - xmouse
y1 = Picture1.Top + Y - ymouse
If (Picture1.Left <> x1) Or (Picture1.Top <> y1) Then
Picture1.Move x1, y1
End If
End If
End Sub

Private Sub Picture1_MouseUp(Button As Integer, _
Shift As Integer, X As Single, Y As Single)
dragging = False
End Sub


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com