How do I make the sound off but the music is on?

Get help using Construct 2

Post » Tue Mar 04, 2014 3:36 am

Is it possible that the sound effects are in silent but the background music is on?
Last edited by Banjo on Tue Mar 04, 2014 3:40 am, edited 1 time in total.
B
1
Posts: 3
Reputation: 131

Post » Tue Mar 04, 2014 3:38 am

Do you mean when the user presses a button? E.g. They can mute the sounds and music separately?
B
9
S
3
Posts: 22
Reputation: 755

Post » Tue Mar 04, 2014 3:41 am

yes... do you know how to do that?
B
1
Posts: 3
Reputation: 131

Post » Tue Mar 04, 2014 3:51 am

Since music and sounds are separate, what I do is have a variable for playSounds and one for playMusic. On any event that plays sounds or music I add a condition that checks if the playSounds is true, same thing for playMusic. To shut them off, I have a button in my pause menu that lets them set it on or off. It's just a sprite with words in it for On and Off. It has 2 animation frames, one has the word "On" and one has the word "Off". When playSounds is true it is set to frame 1 so it shows "On". When it is false I set it to frame 2 which is "Off". Also I have an even that when the button is clicked and playSounds is set to false the stop all sounds event triggers. I do the same thing for music.

If you start music in your start of layout events, just add a sub event to it for playMusic = True. That way if music is off, the music won't play at the start of layout.

You may also want to make sure you save the game when they change this if you want it to remember their settings the next time they play.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583

Post » Tue Mar 04, 2014 3:52 am

Another way of doing this if you want to toggle sound and music both:

Personally, I would use a variable to do this. I'm not sure how you have everything organized, but I would create a global variable system that works sort of like this (let's say your variable is called "soundtoggle"- I'll explain how to code it in a minute). First, however, assume the following is what you want.
When soundtoggle = 0, all sounds are on.
When soundtoggle = 1, the game sounds are off.
When soundtoggle = 2, the music is off.
When soundtoggle = 3, both the game sounds and music are off.
Then add in logic to your event sheets that will only enable the game sounds to play if soundtoggle = 0 or 2, and only enabling music to play if soundtoggle = 0 or 1. Then (using buttons, keys, or however you want it- I'll assume you want to use keys- "m" to toggle music on and off and "s" to toggle sound on and off- for now but buttons should work similarly, I am just not that familiar with them) make an event sheet to do this (assume that "if" simply means there is a new event):
if "m" pressed:
-----if soundtoggle = 0 -------- soundtoggle = 2
-----else
-----if soundtoggle = 1 --------soundtoggle = 3
-----else
-----if soundtoggle = 2 --------soundtoggle = 0
-----else
-----if soundtoggle = 3 --------soundtoggle = 1

if "s" pressed
-----if soundtoggle = 0 --------soundtoggle = 1
-----else
-----if soundtoggle = 1 --------soundtoggle = 0
-----else
-----if soundtoggle = 2 --------soundtoggle = 3
-----else
-----if soundtoggle = 3 --------soundtoggle = 2

Does this make sense?
B
9
S
3
Posts: 22
Reputation: 755

Post » Tue Mar 04, 2014 4:11 am

I'm still understanding it.. Is there a way I can put the sound into a group and the music into a group so that when i press a button the sound group will disable
B
1
Posts: 3
Reputation: 131

Post » Tue Mar 04, 2014 7:27 am

They are already in groups. Sounds and Music are two separate groups. However, if you turn them off, you also need to make sure that any place in your code that would normally start them checks to see if they are supposed to start. That is what the above examples do for you. Outside of that you may want to think about reading the manual and doing the tutorials. You will get much more out of working with them then by listening to us when you haven't worked much with them yet.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,583


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, FabianB, Wartexnik and 48 guests