I Wanna Community

Fangames => Game Design => Programming Questions => Topic started by: 128-Up on August 27, 2015, 10:40:36 AM

Title: Making a song only play once
Post by: 128-Up on August 27, 2015, 10:40:36 AM
I'm messing around with avoidances, and I want to know how to make it so the background music does not repeat after it's finished.

How do I do this?
Title: Re: Making a song only play once
Post by: klazen108 on August 27, 2015, 11:59:10 AM
This depends on which engine you're using.

In GM8/8.1, music is started with either the sound_play or sound_loop functions. If you were coding it yourself you could simply choose which one you wanted.
In GM8/8.1 with FMOD, you use FMODSoundPlay or FMODSoundLoop in the same way as above.
In GMS, you use audio_play_sound(song,0,0) for non-loop or audio_play_sound(song,0,1) for loop, where song is the sound resource name.

In Seph's engine or the KS engine, there is a musicFunctions script that starts the music based on the current room; you could add logic to see "is this the avoidance song, if so, do play, not loop".
In Yuuutu's engine or YoYoYo's engine, there is a playMusic object that starts the song, you could make a separate one that plays instead of loops.