Animated Buttons

From VbGORE Visual Basic Online RPG Engine

Here's a tutorial for making animated buttons on your "Connect" and "New Account" screen. If you move your mouse over the button, you will see an other image, and when you click on the image you will see yet another image. I only explain how to animate the "Connect" button in this tutorial, but with this you can easily do the rest by yourself.

Grh's

First, you need to add 3 images to your Grh folder: - "Connectbutton1.bmp" : this is the image you see at the begin. - "Connectbutton2.bmp" : this is the image you see when you move your mouse over the button. - "Connectbutton3.bmp" : this is the image you see when you click on the button.

be sure to save them as .bmp, and call them "Connectbutton1" , "Connectbutton2" and "Connectbutton3"!

Client

Now open up the "GameClient" and go to "frmConnect". Add 3 new images, called "image1" , "image2" and "image3". Make sure Image1 is on top, and Image3 at the bottom.

Now, open up the code from "frmConnect". Find the sub "Form_Load()" and at the bottom of the sub, above "End sub", add this:

<vb> 'connectbutton

   Image1 = LoadPicture(App.Path & "\Grh\Connectbutton1.bmp")
   Image2 = LoadPicture(App.Path & "\Grh\Connectbutton2.bmp")
   Image3 = LoadPicture(App.Path & "\Grh\Connectbutton3.bmp")</vb>

under that sub add this sub:

<vb>Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Image1.Visible = True Image2.Visible = False End Sub</vb>

Under that add this sub:

<vb>Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) Image1.Visible = False Image2.Visible = True End Sub</vb>

And under that add this sub:

<vb>Private Sub Image2_Click() ClickConnect Image2.Visible = False Image3.Visible = True End Sub</vb>

Sound Add-on

Here's a nice add on for animated buttons. What it does is, when you move your mouse over the button or click the button, it plays a sound.

Ok first, add the .wav sound that you want to be played when you move your mouse over the button to the 'sfx' folder. Then open up "sfx.ini" and change "NumSfx=8" to "numSfx=9".

Client

Now open up Gameclient.vbp and go to the code of "frmConnect". Find:

<vb>Private Sub Image1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)</vb>

And add this in that sub:

<vb>sndPlaySound (App.Path & "\sfx\button.wav"), 0</vb>

Change "button.wav" to the name of your soundfile.

Now, go to the "sound .bas" module and add this under Option Explicit:

<vb>Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" _ (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long</vb>

Now you hear a sound when you move your mouse over the button! Yay!

Sound when click on button

this is how to play a sound when you click on the button:

Ok first, add the .wav sound that you want to be played when you click on the button to the 'sfx' folder. Then open up "sfx.ini" and change "NumSfx=9" to "numSfx=10".

Now open up Gameclient.vbp and go to the code of "frmConnect". Find:

<vb>Private Sub Image2_Click()</vb>

And add this in that sub:

<vb>sndPlaySound (App.Path & "\sfx\button2.wav"), 0</vb>

Change "button2.wav" to the name of your soundfile.

By:Tharsten

Personal tools