How to fix this sound button?

I found this somewhere else on this forum:

Rule: When touch is pressed
Rule: ---nested in above rule-- When Game.Audio.Sound Volume = 1
Change Attribute Game.Audio.Sound Volume to 0
Change Attribute Game.Audio.Music Volume to 0
Change Image Bluebut_sound0
Otherwise
Change Attribute Game.Audio.Sound Volume to 1
Change Attribute Game.Audio.Music Volume to 1
Change Image Bluebut_sound1

And I was able to do it this way but to make it perfect for my situation I want text instead of an image. How do I replace the image by text and have it still working? 1 click is sound off, another click is sound back on.

I hope you guys can help me here!

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Replace the Change Image behaviors with Display Text behaviors.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • SocksSocks London, UK.Member Posts: 12,822

    Here's a simpler way to switch the sound on and off.

    When touch is pressed . . .
    Change Audio volume to 1-Audio volume
    Change Music volume to 1-Music volume

  • JelmerHPJelmerHP Member Posts: 37

    @Socks said:
    Here's a simpler way to switch the sound on and off.

    When touch is pressed . . .
    Change Audio volume to 1-Audio volume
    Change Music volume to 1-Music volume

    And then for the text:
    Display Sound On

    Else:
    Display Sound Off

    Or something?

  • SocksSocks London, UK.Member Posts: 12,822

    @JelmerHP said:
    Or something?

    Yes.

  • JelmerHPJelmerHP Member Posts: 37

    Cool! Thanks for your quick responses and help guys!

    Gonna try it tomorrow and see what happens :)

  • JelmerHPJelmerHP Member Posts: 37

    Okay, I got this now:

    Rule: when touch is pressed
    Do: Change game audio to 1-game audio
    Change game volume to 1-game volume
    Display text: Sound On
    Else: Display text: Sound Off

    However, when I click the button it shows Sound Off and when I release press it switches back to Sound On. It should switch to Sound On on second click. How do I fix this?

    I'm still a newbie, still learning :p

  • JelmerHPJelmerHP Member Posts: 37

    Got an idea @Socks ?

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Make a separate rule that says If attribute game.audio=0, Display Text 'Sound Off'; Else Display Text 'Sound On'

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • JelmerHPJelmerHP Member Posts: 37

    @tatiang said:
    Make a separate rule that says If attribute game.audio=0, Display Text 'Sound Off'; Else Display Text 'Sound On'

    Whoot! Thanks! That did it!

    But one more question: when I click on Sound On it switches to Sound Off, this is how it should be. But 'Sound' from Sound Off is like 1 pixel more to the left than the 'Sound' of Sound On. Is there any way to fix this or should I just be content with it as it is?

  • SocksSocks London, UK.Member Posts: 12,822

    @JelmerHP said:
    But one more question: when I click on Sound On it switches to Sound Off, this is how it should be. But 'Sound' from Sound Off is like 1 pixel more to the left than the 'Sound' of Sound On. Is there any way to fix this or should I just be content with it as it is?

    Make them both range left (they are currently centred) and then use the offset value to reposition them where you want.

  • JelmerHPJelmerHP Member Posts: 37

    You guys are so genius! :open_mouth: Thanks a lot!

  • JelmerHPJelmerHP Member Posts: 37

    I used this for my sound button as @Socks said:

    When touch is pressed . . .
    Change Audio volume to 1-Audio volume
    Change Music volume to 1-Music volume

    But somehow it doesn't turn my sounds off if I click it. I have for every mouse a play music behavior when mouse is over the actor to play a sound but my sound button should turn them off right?

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @JelmerHP said:
    I have for every mouse a play music behavior when mouse is over the actor to play a sound but my sound button should turn them off right?

    Eats, shoots and leaves ! :)

    How many mice do you have ?

    How have you got the play music behaviour to play a sound !!?

    :wink:

  • JelmerHPJelmerHP Member Posts: 37

    Lol that sentence

  • JelmerHPJelmerHP Member Posts: 37

    It should be every button :pensive:

    And when I make a play music or play sound I can't select the sound in the drop down menu but when I drag the sound in it shows a play music behavior and it works. But somehow I can't turn them off using the sound button

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    ...

  • JelmerHPJelmerHP Member Posts: 37

    I'd rather have you saying something useful instead of ...

  • SocksSocks London, UK.Member Posts: 12,822
    edited March 2015

    @JelmerHP said:
    I'd rather have you saying something useful instead of ...

    I made a suggestion, but then thought it might not be applicable in this situation, so I deleted the post, when you delete a post you cannot simply leave a blank page, so I usually just type some dots in.

  • JelmerHPJelmerHP Member Posts: 37

    Aah I see. Sorry about it then, I didn't know that

  • JelmerHPJelmerHP Member Posts: 37

    well, I kinda did it. I converted my soundfiles (again) to wav, then imported them in GS. I made an integer game attribute 'Sound On' and for every button I made a rule saying:

    If mouse position is over actor and game attribute Sound On is 1,
    play sound

    and for the sound button I used a change attribute so sound on goes to 0. It's more work than it should be but it works at least...

Sign In or Register to comment.