External Exam Download Resources Web Applications Games Recycle Bin

music & sound effects | gml

put a spriteless objSound into room, and go Create Sound:

rename to sound_background and add a music file, has to be .mp3, .ogg, .wav or .wma:

create two sounds sound_background and sound_effect:

objSound Create

// audio_play_sound(Index, Priorty, Loop);

audio_play_sound(sound_background, 0, true);

/* Index: name of sound to play. */
/* Priority: lower priority sounds will be stopped
in favour of higher priority sounds. */
/* Loop: Sets the sound to loop or not. */

objSound Step

if keyboard_check_pressed(vk_space){
    audio_play_sound(sound_effect, 1, false);
}

// can stop specific sounds using audio_stop_sound:
// audio_stop_sound(sound_background);

if keyboard_check_pressed(vk_f1){
    audio_stop_sound(sound_effect);
}

// can stop all sounds with:
// audio_stop_all();

if keyboard_check_pressed(vk_f2){
    audio_stop_all();
}

add music and sound effects to your previous games