Add dynamic_cast for playSound
makes it so developers don't need to dynamic_cast any time they want to play sound
This commit is contained in:
@@ -10,7 +10,7 @@ public:
|
|||||||
~SoundService(void);
|
~SoundService(void);
|
||||||
|
|
||||||
float getMusicVolume();
|
float getMusicVolume();
|
||||||
void playSound(SoundInstance* sound);
|
void playSound(Instance* sound);
|
||||||
private:
|
private:
|
||||||
float musicVolume;
|
float musicVolume;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -525,10 +525,10 @@ void PartInstance::onTouch()
|
|||||||
case Enum::Sound::NoSound:
|
case Enum::Sound::NoSound:
|
||||||
break;
|
break;
|
||||||
case Enum::Sound::Victory:
|
case Enum::Sound::Victory:
|
||||||
sndService->playSound(dynamic_cast<SoundInstance*>(sndService->findFirstChild("Victory")));
|
sndService->playSound(sndService->findFirstChild("Victory"));
|
||||||
break;
|
break;
|
||||||
case Enum::Sound::Boing:
|
case Enum::Sound::Boing:
|
||||||
sndService->playSound(dynamic_cast<SoundInstance*>(sndService->findFirstChild("Boing")));
|
sndService->playSound(sndService->findFirstChild("Boing"));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -71,10 +71,15 @@ SoundService::~SoundService(void)
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void SoundService::playSound(SoundInstance* sound)
|
void SoundService::playSound(Instance* sound)
|
||||||
{
|
{
|
||||||
std::string soundId = sound->getSoundId();
|
// Try to dynamic_cast it to SoundInstance
|
||||||
AudioPlayer::playSound(GetFileInPath(soundId));
|
SoundInstance* sndInst = dynamic_cast<SoundInstance*>(sound);
|
||||||
|
if(sndInst != NULL)
|
||||||
|
{
|
||||||
|
std::string soundId = sndInst->getSoundId();
|
||||||
|
AudioPlayer::playSound(GetFileInPath(soundId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float SoundService::getMusicVolume()
|
float SoundService::getMusicVolume()
|
||||||
|
|||||||
Reference in New Issue
Block a user