Jump to content

Cannot STOP sounds...


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?


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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

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