Fangames > Programming Questions
BGM Folder
bananaguy12:
In games like 'kill the needle games 2' or 'kamilia 3' :denKamilia_v2: I noticed there is a separate folder where all the bgm is stored, and the bgm is not stored in the gamemaker file. Somehow the game pulls the music from the folder or something. I was wondering how do I do this? Thanks.
Katz:
Either external .ogg loaders (FMOD, SuperSound) or sound_add();
Derf:
This method only works for GM8/8.1:
--- Code: ---bgm = sound_add(working_directory+"\BGM\song.mp3",3,0);
if(!sound_isplaying(bgm)){
sound_loop(bgm);
}
--- End code ---
Obviously change the first line to match your folder name + song name, but if it's inside the folder where the game is you should be set. Might need a little tweaking to get it to work with your specific sound engine though.
klazen108:
Note that if you're doing sound_add, you should only do this once in your game, say at game start (and it will take time, so you should only load one song per step, otherwise the game will look like it's freezing). This is what's happening during that loading bar at the beginning of K3 - it's adding one sound, then ticking the loading bar, adding another sound, ticking the loading bar, until it's done.
Never load sounds elsewhere! If, for example, you tried to load the sound on room start in the room you want to play the music in, it's going to create a new copy of the sound every time you load that room! You'll notice the slow restart time, and it probably wouldn't take long for the game to crash from memory errors due to the memory being full of the songs you loaded. (Note that this advice doesn't apply to you if you're advanced enough to understand the tradeoffs and always release any allocated memory)
tl;dr only use sound_add at the start of your game, never anywhere else
Derf:
Yeah I really should have clarified a lot of that when I wrote my response, thank you Klazen :~)
Navigation
[0] Message Index
[#] Next page
Go to full version