How do I stop a sounds on touch?

veshvesh Member Posts: 1
Hi guys complete newbie here so explain as simple as possible!
I am making a sound board app. I made an image for a button and to play the sound on it, I'd put in the touch block, then in do on that drag in the sound I want to play.
That works but if I press on another sound or even change scenes, any sound pressed that hasn't finished yet keeps continuing. I want to be able to stop it again on touch or stop if I have touched somewhere else on the screen. Can this be done?
Also what is difference between sound and music? My sounds are .ogg files (converted from mp3 as they do not work and wav is just way too big) and I see the play music block but no option to choose out of the ogg files so then can't stop music. Why isn't there a stop sound block?
Thanks :)

Comments

  • cBrookscBrooks Member, PRO Posts: 40
    I am not sure if you can stop sounds, so I'd import them as music.
    Create or select the actor you want to stop the music (if you want to click anywhere to stop it I suggest you make a background actor taking up the screen) Double click the actor to enter it. Create a rule (top right) and click the 'mouse position' text in the rule and change it to 'touch'. After that go to the behaviours section (bottom left) and find 'stop music'. Drag it into the rule and voila! Hope this helped. Feel free to ask a question.
  • cBrookscBrooks Member, PRO Posts: 40
    If you wanted to touch the button again to stop the music, read my comment above. You also said that if you touched another button it would automatically stop the previous music and play different. This is possible and very easy. Heres how: Create an actor that is going to be one of the buttons. Make a rule (top right) and click the 'mouse position' text and change it to 'touch'. Then go to the behaviours section (bottom left) and find 'play music'. Drag it into the rule you created. After that select the music you want it to play and test what you have so far. It should be that when you click the button actor on the screen it plays the music you wanted. Now create another actor which will be your second button. Double click it and create a rule. Again, change the 'mouse position' to 'touch'. Go to the behaviours section and find 'stop music', and drag it into the rule. Then, go to the behaviours section and find the 'play music' button. Drag this into the rule as well and select the next track/music you want to play. MAKE SURE THAT THE 'PLAY MUSIC' IS BELOW THE 'STOP MUSIC' OR IT WILL NOT WORK.

    Extra:
    You might find that you only want the music to play once but instead it loops. To fix this go to the 'play music' behaviour in your rule and un-check the little 'loop' box. I hope this helped, feel free to ask any questions.
  • veshvesh Member Posts: 1
    Thanks for the replies. I am a bit confues but I'll try my best.

    How do I import the sounds as music? I just chose the files and it made them sounds automatically
Sign In or Register to comment.