Audio narration on/off button

fiabanfriendsfiabanfriends Member Posts: 16
edited November -1 in Working with GS (Mac)
i need to make a sound file turn on and off with the touch of a button. how do i do this. i can get to start but not stop. please help

Comments

  • FloridaGamesFloridaGames Member Posts: 328
    When actor is pressed and
    attribute game.sound = 1
    play music
    change attribute game.sound to 0

    when actor is pressed and
    attribute game.sound = 0
    stop music

    or you can use pause music instead of stop music if you dont want it to start over

    change attribute game.sound to 1.
  • fiabanfriendsfiabanfriends Member Posts: 16
    nice thanks
  • fiabanfriendsfiabanfriends Member Posts: 16
    ok for some reason this is not working for me, do i add the attribute game.sound = 1 inside the first when touch is pressed rule?
  • fiabanfriendsfiabanfriends Member Posts: 16
    will the stop music work with a sound file these narrations are sound files not music files
  • FloridaGamesFloridaGames Member Posts: 328
    I just tried it with a sound and it will not work you will need to import it as music.
    Also add a timer for the change game.sound
    so make it
    When actor pressed and
    game.sound = 0
    After 0.1 second [x] run to completion
    change attribute game.sound to 1

    and add a timer on the other change sound attribute
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    nooo dont use a rule like that with a timer to toggle that attribute, thats silly

    Make your own attribute called musicoff

    Have a rule in your music on off button when touch is pressed:

    change attribute musicoff to (musicoff+1)%2

    that will toggle it back and forth beween 0 and 1 no timer needed

    then just have a rule when attribute music off=1 change attribute game music volume to
    then in the otherwise section of that rule change attribute game music volume to 1
  • ChaserChaser Member Posts: 1,453
    To do it as sound set a secondary actor to spawn that plays sound when your button change attribute is 1 and destroy that sound playing actor when the attribute is 0
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    why on earth would you spawn and destroy to stop music/sound....
  • ChaserChaser Member Posts: 1,453
    Simple it works for sounds!
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    Chaser said:
    To do it as sound set a secondary actor to spawn that plays sound when your button change attribute is 1 and destroy that sound playing actor when the attribute is 0

    I hope you dont plan on playing that sound much. There will probably be some lag time also.
  • ChaserChaser Member Posts: 1,453
    Actually instant playback and works great at least in my games
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    @chaser and its the stupidest thing ive ever heard lol no offense, you can stop sound probably alot more effeicently, AND easier and with less rules

    @fiabanfriends

    do what i posted above itll work like a charm for you
  • fiabanfriendsfiabanfriends Member Posts: 16
    I need it as a sound to control the volume, i just need to turn the sound on and off with a button thats all no biggy tshirtbooth has a fix for it but i can't find it
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    i told u what to do. If u want to change sound instead of music use the game audio music attribute and not game audi sound
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934


    Heres TSB's video.

    Same thing John has posted.
  • ChaserChaser Member Posts: 1,453
    JohnPapiomitis said:
    @chaser and its the stupidest thing ive ever heard lol no offense, you can stop sound probably alot more effeicently, AND easier and with less rules

    @fiabanfriends

    do what i posted above itll work like a charm for you

    Let's keep it positive John!
    He asks for advice on a sound and not music therefore I provide one.
    Perhaps you can provide one of your SMART easy examples on how to stop a sound as I'm sure we'd all like to know.
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    Chaser said:
    Let's keep it positive John!
    He asks for advice on a sound and not music therefore I provide one.
    Perhaps you can provide one of your SMART easy examples on how to stop a sound as I'm sure we'd all like to know.

    haha i didnt mean that as me attacking you, im just saying that not really good advice to give

    i posted the best and easiest way above, which is also the same way shown in the video im pretty sure

    you use modulo to toggle a attribute between 1 and 0 for each touch, and base your sounds off that. its like 4 rules if that

    cheers
  • ChaserChaser Member Posts: 1,453
    I guess it's just unfortunate that GS doesn't provide a pause and stop sound behavior
Sign In or Register to comment.