Whils writing a small interface i kept having the following problem. I want a sound (ogg) to play once when mouse moving over a button object. Now playing the sound isn't the problem. It's getting the sound to play once. You see i have this structure set up for my buttons.
pseudocode
Now as you noticed the update button is called from within a loop and the update function looks like this...
notice where it says playsound there.... Thats where id add playsound <channel name> but it keeps playing it in a repetative way that maked it all distorted. How would i go abot playing it only once every new button id? (A\ID% == button id)
pseudocode
Button Type CreateButton GameLoop UpdateButton EndGameLoop FreeButton
Now as you noticed the update button is called from within a loop and the update function looks like this...
For A.BUTTON = Each BUTTON If MouseX() > A\XP% And MouseX() < A\XP% + ImageWidth(BTN_MENU%) And MouseY()>A\YP% And MouseY()<A\YP% + ImageHeight(BTN_MENU%) And MouseDown(1)=0 A\STATE% = 1 ; <<<<<< PLAYSOUND HERE >>>>>>>> ElseIf MouseX() > A\XP% And MouseX() < A\XP% + ImageWidth(BTN_MENU%) And MouseY()>A\YP% And MouseY()<A\YP% + ImageHeight(BTN_MENU%) And MouseDown(1)=1 MOUSEUP% = 1 A\STATE% = 2 Else A\STATE% = 0 EndIf If MouseX() > A\XP% And MouseX() < A\XP% + ImageWidth(BTN_MENU%) And MouseY()>A\YP% And MouseY()<A\YP% + ImageHeight(BTN_MENU%) And MOUSEUP% = 1 PlaySound SND_MNUD% Select A\ID% Case GAMEMENUPLAY% GAMEMODE% = GAMETYPEGAME% End Select MOUSEUP% = 0 EndIf ButtonDraw(A\CAPTION$,A\XP%,A\YP%,A\STATE%) Next
notice where it says playsound there.... Thats where id add playsound <channel name> but it keeps playing it in a repetative way that maked it all distorted. How would i go abot playing it only once every new button id? (A\ID% == button id)