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
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;
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.
Worked like a CHARM! I had to do what Calin said, but yes. It all works now. Thanks!
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
You won the innovation award! Don't be greedy with the lifetime. Think of poor Andail!! :D
Now that's class. Nice one, Steve!
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.
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?
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
I had been looking for something that would simplify this task for a long time. Thank you very much, Khris!