Quantcast
Viewing all articles
Browse latest Browse all 494966

iphone真机先home键然后恢复进入app后的音效问题

(1)js端
onOC: function(){
console.log('####onOC begin####');
var flag=false;
if(cc.director.isPaused()){
cc.find('Game/pause').getComponent(cc.Button).interactable=true;
cc.director.resume();
cc.audioEngine.resumeMusic();
cc.audioEngine.resumeAllEffects();
flag=true;;
console.log('####onOC 切出前,暂停恢复####');
}
console.log('####onOC end####');
return flag;
},
(2)oc端
void AppDelegate::applicationDidEnterBackground()
{
NSLog(@"###切出游戏iOS端###");
auto director = Director::getInstance();
/*
director->stopAnimation();
director->getEventDispatcher()->dispatchCustomEvent("game_on_hide");
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
*/
bool paused=ScriptingCore::getInstance()->evalString("cc.find('Game').getComponent('Player').onOC();", NULL);
NSLog(@"###iOS paused:###%d",paused);

如上为什么把(2)的原有代码注释后,调用onOC,无论是否点击游戏内暂停,切出游戏时,onOC都是返回true呢?即使不调用onOC,游戏依然可以暂停是为什么呢?被注释的代码没有起到作用呢,当按home键切出的时候还有别的代码执行了游戏的暂停么?
求助官方技术大神@panda @jare


Viewing all articles
Browse latest Browse all 494966

Trending Articles



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