サスペンド・レジューム処理
ホームボタンの押下等によりアプリケーションがサスペンドした場合、レジューム時に正常に音声再生を再開するためには、プラットフォーム毎の処理を記述する必要があります。
iOSの場合は、アプリケーションのサスペンド及びレジュームそれぞれのコールバック関数内において、 サウンド再生の一時停止と再開を明示的に行う必要があります。 cocos2d-xアプリケーションの場合は、ApplicationクラスのapplicationDidEnterBackground関数及びapplicationWillEnterForeground関数内で、 サウンド停止/再開関数呼び出しを追加します。
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground() {
    Director::getInstance()->stopAnimation();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    /* サスペンド時は音声を一時停止 */
    criAtomEx_StopSound_ANDROID();
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    /* サスペンド時は音声を一時停止 */
    criAtomEx_StopSound_IOS();
#endif
}

// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground() {
    Director::getInstance()->startAnimation();

#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
    /* リジューム時は音声を再開 */
    criAtomEx_StartSound_ANDROID();
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
    /* サスペンド時は音声を一時停止 */
    criAtomEx_StopSound_IOS();
#endif
}

CRI Middleware logo Copyright (c) 2012-2018 CRI Middleware Co., Ltd. CRI ADX2 LE マニュアル (for Cocos2d-x) SDKVer.2.10版