Mouse over sound
in
Programming Questions
•
1 year ago
Ok, I've programmed my menu options. They highlight green whenever the mouse cursor is over them and return to black when my mouse isn't over it.
Now I want a sound to play once when I've highlighted an option. Here's what I'm basically doing (not real code):
- void draw()
- {
- int text_r = 0;
- int text_g = 0;
- int text_b = 0;
- if (mouseOverOption() == true)
- {
- text_g = 200;
- playSound();
- }
- drawText("Option", text_r, text_g, text_b);
- }
The problem is that if my mouse lingers on an option, the sound plays countless times rapidly. How can I change my code so that sound is only played once when you highlight an option?
Thanks.
1