sound_exists

Checks whether the given sound exists.

Syntax:

sound_exists(index);


Argument Description
index The index of the sound to check the existence of.


Returns: Boolean


Description

This function returns whether a sound exists (true) or not (false). Note that if the index you search for has not been initialised previously, this function will cause an error as it is searching for non-existent asset indices.


Example:

if sound_exists(global.Music)
   {
   sound_loop(global.Music);
   }
else
   {
   global.Music = sound_add(working_directory + "\MainMusic.mp3", 1, 0);
   sound_loop(global.Music);
   }

The above code checks to see if a sound exists. If it does it is set to play in a loop, but if it does not, it is loaded into memory from an external source and then set to loop.


Back: Legacy Sound
Next: sound_get_name
© Copyright YoYo Games Ltd. 2018 All Rights Reserved