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.
Have you tried using tags? Check it here: https://www.scirra.com/manual/109/audio
Yes I have, they were the first thing I tried but it only mutes the sound on the Menu layout and not the others.
It happens while running the game with a we browser? I have some problems after exporting to Ejecta and tagging sounds.
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?
use a global variable for the volume, and put this variable into the play.
And set this variable to mute volume.
Develop games in your browser. Powerful, performant & highly capable.
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?
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.
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?
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.