I have this code:
[embed=425,349]
function hNewGame_MouseMove()
{
oNewGame.Graphic = 5;
AudioChannel* Click = aMenuClick.Play(eAudioPriorityNormal, eOnce);
Click.Volume = 50;
}
[/embed]
My Problems:
1) When the mouse is moved over oNewGame, which is the New Game Button on the menu, the click happens each time the mouse moves a pixel, whereas I want it to only play once.
2) I want the Graphic of oNewGame to go back to how it was if the mouse is not over it.
Empty your function, add the room's RepExec event, then use this:
Hotspot*old_h;
function room_RepExec() {
Hotspot*h = Hotspot.GetAtScreenXY(mouse.x, mouse.y);
if (h != old_h) { // we have just moved over a hotspot or left one
// new game
if (h == hNewGame) { // mouse moved over hNewGame
oNewGame.Graphic = 5;
AudioChannel* Click = aMenuClick.Play(eAudioPriorityNormal, eOnce);
Click.Volume = 50;
}
else if (old_h == hNewGame) { // mouse left hNewGame
oNewGame.Graphic = 4;
}
// other buttons here
old_h = h;
}
}
(Also, just in case there are typos, try to fix them yourself this time using the manual and AGS's auto-complete feature :))
Edit: also, if you're going to use the same audio for all the buttons, the audio code can be typed once instead of separately for each button.
Just move it to if (old_h.ID == 0) { // mouse left hotspot 0 (no hotspot)
AudioChannel ...
...
}