send close event to JS (#3527)

This commit is contained in:
mmyduckx
2021-05-21 11:37:13 +08:00
committed by GitHub
parent 6d9139e723
commit 76d15cafa4
24 changed files with 665 additions and 592 deletions
@@ -85,22 +85,17 @@ bool Game::init()
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void Game::onPause()
{
void Game::onPause() {
cc::Application::onPause();
cc::CustomEvent event;
event.name = EVENT_COME_TO_BACKGROUND;
cc::EventDispatcher::dispatchCustomEvent(event);
cc::EventDispatcher::dispatchEnterBackgroundEvent();}
// this function will be called when the app is active again
void Game::onResume()
{
cc::Application::onResume();
cc::CustomEvent event;
event.name = EVENT_COME_TO_FOREGROUND;
cc::EventDispatcher::dispatchCustomEvent(event);
cc::EventDispatcher::dispatchEnterForegroundEvent();
cc::EventDispatcher::dispatchEnterBackgroundEvent();
}
void Game::onResume() {
cc::Application::onResume();
cc::EventDispatcher::dispatchEnterForegroundEvent();
}
void Game::onClose() {
cc::Application::onClose();
cc::EventDispatcher::dispatchCloseEvent();
}