Quantcast
Channel: Cocos中文社区 - 最新主题
Viewing all articles
Browse latest Browse all 88737

游戏后台,音乐仍然播放

$
0
0

@zjzjchl 写道:

现在在IOS上遇到一个问题,游戏退到后台,音乐仍然播放;我的代码如下:
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
CCDirector::sharedDirector()->stopAnimation();

if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)

SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
SimpleAudioEngine::sharedEngine()->pauseAllEffects();

endif

//
CCNotificationCenter::sharedNotificationCenter()->postNotification("APP_EVENT_ENTER_BACKGROUND");

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

if (CC_TARGET_PLATFORM != CC_PLATFORM_IOS)

SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
SimpleAudioEngine::sharedEngine()->resumeAllEffects();

endif

//
CCNotificationCenter::sharedNotificationCenter()->postNotification("APP_EVENT_ENTER_FOREGROUND");

}
编译开关是因为IOS上面,自动带有停止播放和恢复播放的能力

朋友们不知道有没有遇到这个问题~

帖子: 1

参与者: 1

阅读整个主题


Viewing all articles
Browse latest Browse all 88737

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>