forked from townforge/townforge
game: allow playing a sfx at non default pitch
This commit is contained in:
parent
6c7fb2fafa
commit
965705d38f
@ -114,7 +114,7 @@ void Audio::SetSFXVolume(float volume)
|
||||
audio->SetMasterGain(Urho3D::SOUND_EFFECT, volume);
|
||||
}
|
||||
|
||||
void Audio::PlaySFX(const char *resource)
|
||||
void Audio::PlaySFX(const char *resource, float pitch)
|
||||
{
|
||||
Urho3D::ResourceCache* cache = GetSubsystem<Urho3D::ResourceCache>();
|
||||
|
||||
@ -124,6 +124,7 @@ void Audio::PlaySFX(const char *resource)
|
||||
auto *soundSource = sfx_node.GetOrCreateComponent<Urho3D::SoundSource>(Urho3D::LOCAL);
|
||||
soundSource->SetAutoRemoveMode(Urho3D::REMOVE_COMPONENT);
|
||||
soundSource->Play(sound);
|
||||
soundSource->SetFrequency(soundSource->GetSound()->GetFrequency() * pitch);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ public:
|
||||
bool SetMusicTrack(const std::vector<std::pair<Urho3D::String, Urho3D::String>> &music);
|
||||
float GetMusicVolume() const;
|
||||
void SetMusicVolume(float volume);
|
||||
void PlaySFX(const char *resource);
|
||||
void PlaySFX(const char *resource, float pitch = 1.0f);
|
||||
void SetSFXVolume(float volume);
|
||||
void PlayAmbience(Urho3D::SoundSource *&ambience_source, const char *resource);
|
||||
void SetAmbienceParameters(Urho3D::SoundSource *ambience_source, float volume, float pitch);
|
||||
|
Loading…
Reference in New Issue
Block a user