Fangames > Programming Questions

sound loop

(1/1)

Junior Nintendista:
How do the music continue when the player dies?

Sudnep:
If you're using yuuutu engine:

In the playMusic Room Start Event:

if (BGM!=0) { if !sound_isplaying(BGM) { sound_loop(BGM) } }

(click to show/hide)BGM != 0 is for the case where the BGM isn't set and you try to play a sound that doesnt exists. (Forgot to set BGM = sound in Creation Code)

sound_isplaying checks if BGM is playing and if it is, it returns true. The "!" infront of it inverts this so if sound_isplaying returns true, it's false and if sound_isplaying returns false, it is true instead. Basically it inverts true/false. (if BGM is not an actual sound the function will always return false)

sound_loop plays BGM on a loop continuing forever. The code previous to this prevents multiple loops of the same sound from playing.

In the creation code (this is set in the room) make BGM = <background music you want to loop>

(click to show/hide)

Junior Nintendista:
It did not work, the music still repeating when I die.

kilgour22:
There's a thread for this already in game design. Find it and it will answer your question.

infern0man1:
https://www.iwannacommunity.com/forum/index.php?topic=33.0

Locked.

Navigation

[0] Message Index

Go to full version