From 5996fe0866f3a58bfee52b108f4a180c5d454e3a Mon Sep 17 00:00:00 2001 From: James Chen Date: Mon, 28 Nov 2016 11:51:37 +0800 Subject: [PATCH] =?UTF-8?q?Don=E2=80=99t=20invoke=20simple=20audio=20engin?= =?UTF-8?q?e=20stuff=20in=20AppDelegate.=20And=20send=20missing=20game=5Fo?= =?UTF-8?q?n=5Fhide=20&=20game=5Fon=5Fshow=20event=20for=20Appdelegate=20i?= =?UTF-8?q?n=20Simulator.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../runtime-src/Classes/AppDelegate.cpp | 5 ----- .../runtime-src/Classes/AppDelegate.cpp | 5 ----- .../runtime-src/Classes/AppDelegate.cpp | 5 ----- .../runtime-src/Classes/AppDelegate.cpp | 15 ++++++--------- 4 files changed, 6 insertions(+), 24 deletions(-) diff --git a/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp index aecc97df39..7ffb2b7b98 100755 --- a/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-binary/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -17,7 +17,6 @@ #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" -#include "SimpleAudioEngine.h" #include "js_module_register.h" @@ -95,8 +94,6 @@ void AppDelegate::applicationDidEnterBackground() auto director = Director::getInstance(); director->stopAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); - SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); - SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again @@ -105,6 +102,4 @@ void AppDelegate::applicationWillEnterForeground() auto director = Director::getInstance(); director->startAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); - SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); - SimpleAudioEngine::getInstance()->resumeAllEffects(); } diff --git a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp index 77c3e86e6a..0076993a43 100755 --- a/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-default/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -17,7 +17,6 @@ #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" -#include "SimpleAudioEngine.h" #include "js_module_register.h" @@ -94,8 +93,6 @@ void AppDelegate::applicationDidEnterBackground() auto director = Director::getInstance(); director->stopAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); - SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); - SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again @@ -104,6 +101,4 @@ void AppDelegate::applicationWillEnterForeground() auto director = Director::getInstance(); director->startAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); - SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); - SimpleAudioEngine::getInstance()->resumeAllEffects(); } diff --git a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp index 86dc10e9ca..cdd69c3a8d 100755 --- a/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/templates/js-template-link/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -17,7 +17,6 @@ #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" -#include "SimpleAudioEngine.h" #include "js_module_register.h" @@ -94,8 +93,6 @@ void AppDelegate::applicationDidEnterBackground() auto director = Director::getInstance(); director->stopAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); - SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); - SimpleAudioEngine::getInstance()->pauseAllEffects(); } // this function will be called when the app is active again @@ -104,6 +101,4 @@ void AppDelegate::applicationWillEnterForeground() auto director = Director::getInstance(); director->startAnimation(); director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); - SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); - SimpleAudioEngine::getInstance()->resumeAllEffects(); } diff --git a/native/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp b/native/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp index f027a9b115..6b80d7ef7c 100755 --- a/native/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp +++ b/native/tools/simulator/frameworks/runtime-src/Classes/AppDelegate.cpp @@ -17,7 +17,6 @@ #include "base/CCDirector.h" #include "base/CCEventDispatcher.h" -#include "SimpleAudioEngine.h" #include "ide-support/CodeIDESupport.h" #include "runtime/Runtime.h" @@ -34,8 +33,6 @@ AppDelegate::AppDelegate() AppDelegate::~AppDelegate() { - SimpleAudioEngine::end(); - // NOTE:Please don't remove this call if you want to debug with Cocos Code IDE RuntimeEngine::getInstance()->end(); } @@ -70,15 +67,15 @@ bool AppDelegate::applicationDidFinishLaunching() // 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(); - - SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); + auto director = Director::getInstance(); + director->stopAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); } // this function will be called when the app is active again void AppDelegate::applicationWillEnterForeground() { - Director::getInstance()->startAnimation(); - - SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); + auto director = Director::getInstance(); + director->startAnimation(); + director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); }