Muting the sound [Solved]

Would it be possible to mute all the sound in my game, if, for instance, someone wanted to listen to music instead of my incredible sound effects?

I’m thinking it would be a simple keypress, a single key to toggle between on and off.

Cheers.

Steve.

1 Like

hi,
you can play music in spcified channel so you can mute it, and sound effects in other channel. I tried to mute and didn’t worked so I set volume to 0

1 Like

Hi Xisco, thanks for the suggestion.
I should have known it would be so simple, this is GDev!

I ended up doing it slightly differently, I just wanted all the sounds either on or off. For those who might be interested, the code I used is below.

I chose the X key and set it up to toggle. Basically the variable is used to check if the sound is on or off, if it’s off turn it on, and vice versa. The timer is needed because key presses are checked very rapidly, and the toggle would happen too quickly to be useful.
I’ve only been using GDev for a short while, so this might not be the best way of doing it, but if anyone wants to use this you’re welcome.

3 Likes