How do I turn sound off from another layout?

Get help using Construct 2

Post » Sun May 04, 2014 9:46 pm

I'm trying to create a button to turn sound effects off on another layout but I'm having a little trouble with it. I have three layouts, Menu, Game & Game Over. On my menu i've created two buttons, one to turn the music off and one to turn sound effects off.

My music starts on the start of the Menu layout so the music button is working perfectly and turns the music on or off with no issues.

However my sound button doesn't fulyl work as I want this to just turn off sound that plays on all three layouts. I have sound that plays when a button is pressed which is on the Menu & Game Over layout. I also have sound on my Game layout where it makes a sound when the play jumps. I want my sound button to turn all these sounds off when toggled but I can only seem to make it work for the sounds on the Menu layout.

The way I've done my buttons is when it is set to animation frame 0, the music/sound plays. When it is set to frame 1, it should stop/ mute.

Hope someone can help, ive had various different attempts to solve this but to no avail.

Thabks.
B
5
S
2
Posts: 116
Reputation: 867

Post » Sun May 04, 2014 10:14 pm

Have you tried using tags? Check it here: https://www.scirra.com/manual/109/audio
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Mon May 05, 2014 12:15 am

Yes I have, they were the first thing I tried but it only mutes the sound on the Menu layout and not the others.
B
5
S
2
Posts: 116
Reputation: 867

Post » Mon May 05, 2014 12:37 am

It happens while running the game with a we browser? I have some problems after exporting to Ejecta and tagging sounds.
B
24
S
4
G
1
Posts: 177
Reputation: 1,827

Post » Mon May 05, 2014 2:16 pm

I'm running the on Chrome at the moment. The game isn't finished so i'm testing it via Run Layout. Is there any solution to this?
B
5
S
2
Posts: 116
Reputation: 867

Post » Mon May 05, 2014 2:20 pm

use a global variable for the volume, and put this variable into the play.

Exemple: Music_Volume.

And set this variable to mute volume.

Image
B
38
S
13
G
4
Posts: 152
Reputation: 5,147

Post » Mon May 05, 2014 2:32 pm

I've just tried that but when i test the button it makes a weird sound instead of muting. I have two audio files that i want to mute when the button is pressed, over three layouts. Would this do what i need it to do?
B
5
S
2
Posts: 116
Reputation: 867

Post » Mon May 05, 2014 6:58 pm

The way I do it is to create a global variable called soundMuted and by default set it to 0. In each of my events that trigger a sound, I have a condition that checks if soundMuted=0. If soundMuted does not = 0 then the sound does not play. In my menus or layouts where they can toggle sound on/off I just have it set soundMuted to 1 or 0 and if it is being set to 1 I also call stop all sounds.
B
49
S
12
G
10
Posts: 1,833
Reputation: 14,603

Post » Tue May 06, 2014 3:21 pm

I've tried your suggestion but i'm still getting the same problem where it only mutes the sound on the Menu layout and not on the other layouts. I don't know whether i'm doing something wrong or not but i just cant seem to get this to work. Is it possible that i could get a working example to see what i'm doing wrong?
B
5
S
2
Posts: 116
Reputation: 867

Post » Thu May 08, 2014 3:26 pm

I've provided a capx file that i've been working on. So far it just the autorunner game with few added bits such as menu, sound etc.

Hope someone can help me out with this.
You do not have the required permissions to view the files attached to this post.
B
5
S
2
Posts: 116
Reputation: 867


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 28 guests