Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: Dave Gilbert on Wed 03/03/2010 20:44:44

Title: SUGGESTION or help: Button.MouseOverSound()
Post by: Dave Gilbert on Wed 03/03/2010 20:44:44
I was thinking it would be nice to be able to script mouseover sounds for buttons, so they play ONCE when you move the mouse over them. 

I tried to simulate this with the code below:


GUIControl *theControl = GUIControl.GetAtScreenXY(mouse.x, mouse.y);

if (theControl == btn_a1)
    if (IsChannelPlaying(6)==0)
       PlaySoundEx(56, 6);


But all this did was make the sound repeat itself over and over again.  Is there a better way to go about doing this?

Thanks!

-Dave
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Goldmund on Wed 03/03/2010 20:58:02
I'd make a global bool "played_mouseover", and:

if (theControl == btn_a1) {
   if ((IsChannelPlaying(6)==0)&&(played_mouseover==false)) {
      PlaySoundEx(56, 6);
      played_mouseover=true;
      }
  }
else played_mouseover=false;
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Calin Leafshade on Wed 03/03/2010 21:27:18
you might want to store *which* control the mouse was last over too since its quite possible to skip over the gap between buttons in a single game loop.
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Dave Gilbert on Wed 03/03/2010 21:38:57
Worked like a CHARM!  I had to do what Calin said, but yes.  It all works now.  Thanks!
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Kweepa on Thu 04/03/2010 21:53:15
I made a module to do this (for future reference):
http://www.kweepa.com/step/ags/tech/ButtonMouseOverSound.zip
It uses an extender function so you can just put something like this in the global script game_start:

btnInvOK.SetMouseOverSound(aBonk, aDonk);

The second parameter is the mouse off sound. Both params can be null.
Steve
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Dualnames on Thu 04/03/2010 22:03:03
You won the innovation award! Don't be greedy with the lifetime. Think of poor Andail!! :D
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Dave Gilbert on Thu 04/03/2010 22:19:21
Now that's class.  Nice one, Steve!
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: subspark on Sun 07/03/2010 05:36:00
It would be cool to have support for a looping sound for mouse over like a low humming or something. Tying it in with the new AGS audio system and its repeate/play once properties for this would be good.

Cheers,
Sparky.

Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Postmodern Adventures on Wed 27/11/2024 13:34:43
Quote from: Kweepa on Thu 04/03/2010 21:53:15I made a module to do this (for future reference):
http://www.kweepa.com/step/ags/tech/ButtonMouseOverSound.zip
It uses an extender function so you can just put something like this in the global script game_start:

btnInvOK.SetMouseOverSound(aBonk, aDonk);


The second parameter is the mouse off sound. Both params can be null.
Steve

Does anyone have this module in their files?

Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Khris on Wed 27/11/2024 23:51:16
I wrote my own version; it works just like Steve's:

  btnInvOK.SetMouseOverSound(aBonk, aDonk);

The second parameter is the mouse off sound. Both params can be null.

https://drive.google.com/file/d/1UbveGm-lV2KM4OkboO1aJGgBLKhHE66d/view?usp=sharing
Title: Re: SUGGESTION or help: Button.MouseOverSound()
Post by: Postmodern Adventures on Thu 28/11/2024 04:27:44
I had been looking for something that would simplify this task for a long time. Thank you very much, Khris!