Login | Register

Play user selected sound

October 25, 2006, 20:41 by Calle
[loading]
-->
<b>Question:</b> I want to make it so if you press a button (F5 in this case), it asks you for a sound file and plays it as the BGM. I've seen it done in some games (such as HardHat 3) but I can't find anything in the help file about it. Little help please?

<b>Answer:</b> Actually, this is not at all very complicated. Still you can't find it in the manual, because it is a combination of functions. First of all you'll need the dialogue from where the user may select a sound, this you could do with the following function:

get_open_filename(filter,fname)

And then you'll need to add the soundtrack to the game, with the following function:

sound_replace(index,fname,kind,loadonuse)

Comine them by adding replacing a existing soundtrack, like snd_bg, then play it as usually.

Comments

Loading comments... [loading]
.
Users logged in:

game maker articles, game maker examples, game maker tutorials, gmtutorials, game maker questions and answers, game maker crash course, how to create games