sound_replace(index, fname, kind, preload);
Argument | Description |
---|---|
index | The index of the sound to be replace. |
fname | The filename of the new sound. |
kind | The kind of sound it should be added as (legacy Feature) 0=normal, 1=background, 2=3D, 3=multimedia player, for things like MP3s). |
preload | Whether the sound should preload into memory immediately (true) or not (false) (legacy Feature) . |
Returns: Boolean
WARNING!: This function has been deprecated and will
no longer work!
This function will load a sound file from an external source into a
previously created sound asset (normally one from the resource
tree, but you can also replace sounds that have been added using
the sound_add function. This
file can be either a *.wav or a *.mp3. The last two arguments are a
left over from previous versions of GameMaker and can be set
to 0 as they have no effect on the function.
NOTE: Depending on the target platform that is chosen you
are limited as to where you can save and load files from. See
Reference - Files
for more information.
NOTE: You should be aware that if you are using this
function in your HTML5 target game to load resources from an
external server, then, due to XSS protection in browsers, attempts
to load resources from across domains can be blocked and may appear
to return blank results.
if sound_exists(global.Music)
{
sound_replace(global.Music, working_directory +
"\bgm.mp3", 0, 0);
sound_loop(global.Music);
}
The above code checks to see if a sound is indexed in the global variable "Music" and if it is it replaces that sound with another and then sets it to loop.