Issue 14206 (#16201)

* don't trigger applicationWillEnterForeground at first time to be the same as iOS

* rename first to firstTime
This commit is contained in:
minggo 2016-07-25 14:25:48 +08:00 committed by GitHub
parent 5b3eae7be8
commit cc14a06800
1 changed files with 8 additions and 1 deletions

View File

@ -27,10 +27,17 @@ extern "C" {
}
JNIEXPORT void JNICALL Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeOnResume() {
static bool firstTime = true;
if (Director::getInstance()->getOpenGLView()) {
Application::getInstance()->applicationWillEnterForeground();
// don't invoke at first to keep the same logic as iOS
// can refer to https://github.com/cocos2d/cocos2d-x/issues/14206
if (!firstTime)
Application::getInstance()->applicationWillEnterForeground();
cocos2d::EventCustom foregroundEvent(EVENT_COME_TO_FOREGROUND);
cocos2d::Director::getInstance()->getEventDispatcher()->dispatchEvent(&foregroundEvent);
firstTime = false;
}
}