Changing Scene & Stopping a Sound

KatAppsKatApps Member, PRO Posts: 84
Hey all,

I have scenes in a game that contain Sound buttons that when tapped will play ongoing sounds. All the scenes also have Next and Back buttons to change scenes. Currently, if a user hits a Sound button within the scene and then hits the Next button, the sound continues to play into the next scene.

Anyone know how I would get the sound to stop when the user hits the Next or Back button?

Thanks!
Kat

Comments

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited March 2013

    @KatApps Hi Kat, for the sound to stop when a Change Scene behaviour is used, the Run to completion in the Play Sound behaviour needs to be unchecked.

    One thing to watch out for though: if the sounds in your Sound buttons are triggered just by touch rules, and the sound behaviour is unchecked, the sound will only play while touch is pressed.

    One way around this is to give each button it's own boolean "switch":

    Rule: When touch is pressed
    Change Attribute SndA1play to true

    Rule: When SndA1play is true
    Play Sound SndA1play --- Run to completion unchecked
    Timer: After ? seconds ---- ? is the length of the sound, in this case the length of time to play SndA1play
    Change Attribute SndA1play to false

    Hope that helps. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • KatAppsKatApps Member, PRO Posts: 84
    Thanks for your help @gyroscope! =D>

    This seems to be working in that when the scene changes the sound from the previous scene stops.. yay!

    What's happening now though is that the sound on the next scene is automatically being triggered when first entering that scene, without the touch of a button (which is not what I intend for it it do).. have any ideas on how to change this?
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    What's happening now though is that the sound on the next scene is automatically being triggered when first entering that scene, without the touch of a button (which is not what I intend for it it do).. have any ideas on how to change this?
    The only way I can think that the new sound on entering the new scene is playing is if you've made the boolean switches as I suggested game attributes rather than scene attributes. Or the final only way: you've a Play Sound behaviour in an actor without any conditioning Rules: i.e just on it's own so it'll start as soon as the scene starts.

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • KatAppsKatApps Member, PRO Posts: 84
    Yep, you're right, I had it as a game attribute. Seems to be working for now, I'll keep my fingers crossed..

    Thanks again @gyroscope .. your response is much appreciated! :D
  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    You're welcome. :-)

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

Sign In or Register to comment.