Mouse Over Hotspot - PlaySound [SOLVED]

Started by T-Pr, Fri 28/01/2011 22:08:32

Previous topic - Next topic

T-Pr

Hi everyone , i searched my problem everywhere i tried a lot of things but i couldn't solve it. My problem is the same here ;

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=8160.0

let me explain , when i move my mouse over the hotspot i want aMenuC sound to be played ONCE . But in my script ; when i bring mouse over hotspot it happens all the time i can't move my mouse when i do it thousands of aMenuC sounds are playing. My code is ; ( whole room code )

Code: ags


// room script file

function hHotspot1_MouseMove()
{

gCik.Visible = true;
}

function room_Load()
{
  StopMusic();
gGos.Visible =false;
}


function hHotspot1_AnyClick()
{
aMenuC.Play();
QuitGame(1);
}

function room_RepExec()
{
   

if (GetLocationType(mouse.x,mouse.y) == eLocationHotspot) 
 {
  
    aMenuC.Play();
    Wait(1);
    aMenuC.Stop();
 }


}


I tried this ;

aMenuC.Play();

and this ;

aMenuC.Play();
wait(1);

and this
aMenuC.Play();
wait(1);
aMenuC.Stop();

and also i tried them by making wait 's to wait(40) but it wasn't the solution.

i tried putting them in repeadetly execute by the help of if function , and i also tried to put them in mouse over hotspot function , but i couldn't solve it ,please help .

greetings, T-Pr

Icey

#1
Code: ags

 if (Game.DoOnceOnly("Play vocal 1")) {
aMenuC.Play();
}


Try that. It should work.

Also ("Play vocal 1") The text inside can be anything but it must be different all the time. You basically cant have to of these with the same text.

T-Pr

Actually , it worked but now it's just playing once , let me explain my room. It's a menu , there is a window and hotspot1 over the window. When the mouse comes over hotspot i want that sound to be played just once , but when i leave my mouse from the hotspot and bring it back to the same hotspot again , i want that sound to be played again , but just once ofcourse . In my scripts , whenever i move my mouse over hotspot WITHOUT leaving hotspot it always plays that sound.

Thank you , but if there is another solution , i still need help. :)

Icey

#3
No prob. I think I understand what your saying but I dont know how to help you there.  :P

Also this would better help me & others. DO you want the sound to play only when the mouse is on the hotshot like do you want it to stop playing when you move off?

monkey0506

Code: ags
bool played = false;

function room_RepExec()
{
  if (Hotspot.GetAtScreenXY(mouse.x, mouse.y) == hHotspot1)
  {
    if (!played)
    {
      played = true;
      aMenuC.Play();
    }
  }
  else played = false;
}


Try that.

T-Pr

@Studio : Not exactly, i want it to play whenever i move on hotspot . If you try the script i gave first in one room you will understand my problem exactly :). But monkey solved it now.

@Monkey: Thanks a lot :) . We can say that you are my hero for today :D . It's working clearly , thank you again :).

Again guys thank you both :).

monkey0506

I forgot to mention that if you did want the sound to repeat then you can just set the repeat style in the editor, or pass it to the Play function. If you do that then you'll also want to modify the else clause:

Code: ags
  else
  {
    played = false;
    aMenuC.Stop();
  }


Glad to hear you got it working, but I just wanted to include that in case anybody wanted to have something like this with repeating music instead of a clip that only plays once per mouse-over. ;)

SMF spam blocked by CleanTalk