Description
The Sounds
property of the SoundEvent
class is a list of SoundFile
objects. This property allows you to specify multiple sound files that can be played as part of a sound event. When the sound event is triggered, a random sound from this list will be selected and played. This feature is useful for creating varied and dynamic audio experiences by randomly selecting from a pool of sounds.
Usage
To use the Sounds
property, you need to create a SoundEvent
object and populate its Sounds
list with SoundFile
instances. You can then trigger the sound event to play a random sound from the list.
Example
// Create a new SoundEvent
SoundEvent mySoundEvent = new SoundEvent();
// Add sound files to the Sounds list
mySoundEvent.Sounds.Add(new SoundFile("sound1.wav"));
mySoundEvent.Sounds.Add(new SoundFile("sound2.wav"));
mySoundEvent.Sounds.Add(new SoundFile("sound3.wav"));
// Trigger the sound event to play a random sound
mySoundEvent.Play();