fix a bug in SimpleAudioEngine.cpp on bada platform

use float value to change volume
This commit is contained in:
dumganhar 2012-01-11 17:24:46 +08:00
parent 5a411277fb
commit 4848dc9c46
2 changed files with 7 additions and 13 deletions

View File

@ -397,7 +397,7 @@ void SimpleAudioEngine::setBackgroundMusicVolume(float volume)
if (s_pBackPlayer != NULL)
{
s_pBackPlayer->SetVolume(ceil(volume));
s_pBackPlayer->SetVolume(ceil(volume*99));
}
s_fBackgroundMusicVolume = volume;
}
@ -423,7 +423,7 @@ void SimpleAudioEngine::setEffectsVolume(float volume)
{
if (it->second != NULL)
{
it->second->SetVolume(ceil(volume));
it->second->SetVolume(ceil(volume*99));
}
}
s_fEffectsVolume = volume;
@ -446,13 +446,7 @@ unsigned int SimpleAudioEngine::playEffect(const char* pszFilePath, bool bLoop/*
AppLog("CCAudioOut instance must not be NULL, id = %d", p->first);
return 0;
}
p->second->SetVolume((int) (s_fEffectsVolume * 99));
int volume = p->second->GetVolume();
if (s_fEffectsVolume > 0.0f && volume == 0)
{
p->second->SetVolume(1);
}
p->second->SetVolume(ceil(s_fEffectsVolume * 99));
if (AUDIOOUT_STATE_PLAYING == p->second->GetState())
{

View File

@ -151,19 +151,19 @@ void CocosDenshionTest::menuCallback(CCObject * pSender)
break;
// add bakcground music volume
case 10:
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() + 0.1);
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() + 0.1f);
break;
// sub backgroud music volume
case 11:
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() - 0.1);
SimpleAudioEngine::sharedEngine()->setBackgroundMusicVolume(SimpleAudioEngine::sharedEngine()->getBackgroundMusicVolume() - 0.1f);
break;
// add effects volume
case 12:
SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() + 0.1);
SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() + 0.1f);
break;
// sub effects volume
case 13:
SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() - 0.1);
SimpleAudioEngine::sharedEngine()->setEffectsVolume(SimpleAudioEngine::sharedEngine()->getEffectsVolume() - 0.1f);
break;
case 14:
SimpleAudioEngine::sharedEngine()->pauseEffect(m_nSoundId);