public abstract CreateInstance ( ) : SoundInstance, | ||
return | SoundInstance, |
/// <summary> /// Loops a sound. /// </summary> /// <param name="soundBase">The SoundAsset to play.</param> /// <param name="position">The optional position to play it at.</param> /// <param name="volume">The optional volume of the sound.</param> /// <param name="pan">The optional panning of the sound.</param> /// <param name="pitch">The optional pitch adjustment of the sound.</param> /// <returns>The new sound.</returns> public Sound LoopSound(SoundAsset soundBase, Vector2? position = null, float volume = 1, float pan = 0, float pitch = 0) { Sound newSound = soundBase.CreateInstance(); newSound.Volume = volume; newSound.Pan = pan; newSound.Pitch = pitch; newSound.Position = position; newSound.Environment = this; updateSound(newSound, false); newSound.Loop(); soundsPlaying.Add(newSound); return newSound; }
/// <summary> /// Plays a sound. /// </summary> /// <param name="soundBase">The SoundAsset to play.</param> /// <param name="position">The optional position to play it at.</param> /// <param name="volume">The optional volume of the sound.</param> /// <param name="pan">The optional panning of the sound.</param> /// <param name="pitch">The optional pitch adjustment of the sound.</param> /// <param name="fireAndForget">Indicates if the SoundEnvironment should delete the sound once it's finished.</param> /// <returns>The new sound, or null if fireAndForget is true.</returns> public Sound PlaySound(SoundAsset soundBase, Vector2? position = null, float volume = 1, float pan = 0, float pitch = 0, bool fireAndForget = true) { if (fireAndForget && !Active) return null; Sound newSound = soundBase.CreateInstance(); newSound.Volume = volume; newSound.Pan = pan; newSound.Pitch = pitch; newSound.ShoulDestroyOnComplete = fireAndForget; newSound.Position = position; newSound.Environment = this; updateSound(newSound, false); newSound.Play(); soundsPlaying.Add(newSound); return (fireAndForget ? newSound : null); }