How to fix this sound button?
JelmerHP
Member Posts: 37
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
Replace the Change Image behaviors with Display Text behaviors.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
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?
Yes.
Cool! Thanks for your quick responses and help guys!
Gonna try it tomorrow and see what happens
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
Got an idea @Socks ?
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
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?
Make them both range left (they are currently centred) and then use the offset value to reposition them where you want.
You guys are so genius! Thanks a lot!
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?
Eats, shoots and leaves !
How many mice do you have ?
How have you got the play music behaviour to play a sound !!?
Lol that sentence
It should be every button
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
...
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.
Aah I see. Sorry about it then, I didn't know that
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...