Publishes some bgm sounds

This commit is contained in:
Stiffly
2014-06-05 03:14:45 +02:00
parent 76a9081d4b
commit 09971b2d77
6 changed files with 28 additions and 12 deletions
+6 -3
View File
@@ -11,9 +11,12 @@ bool Systems::GameStateSystem::OnFlagCaptured(const Events::FlagCaptured &event)
{
m_InGame = false;
Events::GameOver e;
e.Winner = event.Player;
EventBroker->Publish(e);
Events::GameOver e1;
e1.Winner = event.Player;
EventBroker->Publish(e1);
Events::PlayBGM e2;
e2.Resource = "Sounds/BGM/WilliamTellOverture.mp3";
EventBroker->Publish(e2);
return true;
}
+1
View File
@@ -8,6 +8,7 @@
#include "Components/Player.h"
#include "Events/FlagCaptured.h"
#include "Events/GameOver.h"
#include "Events/PlayBGM.h"
namespace Systems
{
+7 -3
View File
@@ -166,11 +166,15 @@ bool Systems::SoundSystem::PlaySFX(const Events::PlaySFX &event)
bool Systems::SoundSystem::PlayBGM(const Events::PlayBGM &event)
{
FMOD_Channel_Stop(m_BGMChannel);
FMOD_RESULT result;
result = FMOD_Channel_Stop(m_BGMChannel);
if(result != FMOD_OK)
LOG_INFO("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
Sound* sound = ResourceManager->Load<Sound>("Sound2D", event.Resource);
FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_BGMChannel);
result = FMOD_System_PlaySound(m_System, FMOD_CHANNEL_FREE, *sound, false, &m_BGMChannel);
if(result != FMOD_OK)
LOG_INFO("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
FMOD_Channel_SetMode(m_BGMChannel, FMOD_LOOP_NORMAL);
FMOD_Sound_SetLoopCount(*sound, -1);