• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Sound

N

nessabby1

Guest
I got the audio to work and stop perfectly, but now when i go to mouse left click the button again, the music doesnt play again. I have a sound/mute feature in the game. so far im using the object that contains the sound sprite. when i start the game the music is there. then when i click it, the music stops which is good. But then what i want to unmute. it doesnt start the music back. Must i put a "else" some where in the code?
heres the code:
forthe create event i simply have :
background_music = audio_play_sound(background_sound, 100, true);

and for the left mouse release:
audio_stop_sound(background_sound);
.
Also, id like the object sound button to change to my Mute sprite how would i go about doing that.
 
J

Jaqueta

Guest
You need to check if the sound is playing or not with the following function.

Code:
if audio_is_playing(background_sound); //If the sound is already playing
{audio_stop_sound(background_sound);} //Stop the Sound
else
{background_music = audio_play_sound(background_sound, 100, true);}

You can have make the sprite to have 2 subimages, one with the sound on, and the other with the sound off.
Set the image_speed as 0 on the create event, and on the mouse click event, you can simply toogle between 0 and 1.
Code:
image_index=!image_index //This toogle the value between false and true, since this values stand for 0 and 1, we can use it to define our subimage with no problems
 
Top