GameSalad

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

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 Posts: 11,791Member, Sous Chef, PRO, Senior Sous-Chef

    Replace the Change Image behaviors with Display Text behaviors.

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

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

    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 Posts: 37Member

    @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.Posts: 12,822Member

    @JelmerHP said:
    Or something?

    Yes.

  • JelmerHPJelmerHP Posts: 37Member

    Cool! Thanks for your quick responses and help guys!

    Gonna try it tomorrow and see what happens :)

  • JelmerHPJelmerHP Posts: 37Member

    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 Posts: 37Member

    Got an idea @Socks ?

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

    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 Posts: 37Member

    @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.Posts: 12,822Member

    @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 Posts: 37Member

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

  • JelmerHPJelmerHP Posts: 37Member

    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.Posts: 12,822Member
    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 Posts: 37Member

    Lol that sentence

  • JelmerHPJelmerHP Posts: 37Member

    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.Posts: 12,822Member
    edited March 2015

    ...

  • JelmerHPJelmerHP Posts: 37Member

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

  • SocksSocks London, UK.Posts: 12,822Member
    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 Posts: 37Member

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

  • JelmerHPJelmerHP Posts: 37Member

    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.