target os: iOS6.1
audio format: .caf
cocos2dx ver.: 2.1rc0-x-2.1.4
SimpleAudioEngine::playEffectを追ってみたら[CocosDenshion playSound:sourceGroupId:pitch:pan:gain:loop:]でも特にエラーが起きておらず、正常にOpenALのalSourcePlay()が呼び出されているようだ。loadも問題ないし原因不明。
ググったら公式フォーラムでちらほら報告があるだけ。
Sound FX not playing after a while.
http://www.cocos2d-x.org/boards/6/topics/3153
http://www.cocos2d-x.org/issues/2512
とりあえずの対処としてBackgroundに移行する時にend()して、Foregroundにresumeする時にアプリ起動時にpreloadすることで音を鳴らす事ができる(ただしpause~resumeではないので、途中から鳴らす事はできない。)
bool AppDelegate::applicationDidFinishLaunching()
{
// some code ...
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("press_button.caf");
}
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->pause();
CCDirector::sharedDirector()->stopAnimation();
// end
SimpleAudioEngine::sharedEngine()->end();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CCDirector::sharedDirector()->resume();
CCDirector::sharedDirector()->startAnimation();
// preloadEffect
CocosDenshion::SimpleAudioEngine::sharedEngine()->preloadEffect("press_button.caf");
}
ゲーム系で音が鳴らなくなるって結構致命的な気がするんだけど、v2.1.4stableとか、v3.xでは直ってるのかな。不明。
0 件のコメント:
コメントを投稿