Jump to content

Cannot STOP sounds...


lpbr
 Share

Recommended Posts

I have an array with a list of sounds and then I loop barely like this to add them to the game:

for (var i=0;i<=aSounds.length-1;i++)
   window[aSounds[i].name+'_snd'] = game.add.audio(aSounds[i].name);

To play the sound at the desired points of my code I just do:

window[me.name+'_snd'].play() // works fine

However I am not managing to STOP the sound with:

window[me.name+'_snd'].stop(); // instead to stop the sound it just restarts

What am I doing wrong?

Thanks!

Link to comment
Share on other sites

I figured the cause of the problem. I used the onStop event to loop the sound so when it stopped (finished to play) it started again. Of course when I was clicking to force stop it fired the event and restarted the sound. I should use onLoop instead.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...