dispatch show/hide event to js, included "cocos simulator" (#1500)

* add dispatchEnterBackgroundEvent for simulator

* more stable when set canvas size on win32

* add isNan check for float & double

* simplify event dispatch on AppDelegate
This commit is contained in:
leda
2018-09-06 16:39:45 +08:00
committed by minggo
parent b46209b4e7
commit 4ca166e109
6 changed files with 21 additions and 25 deletions
@@ -27,7 +27,6 @@
#include "cocos2d.h"
#include "cocos/scripting/js-bindings/event/EventDispatcher.h"
#include "cocos/scripting/js-bindings/event/CustomEventTypes.h"
#include "ide-support/CodeIDESupport.h"
#include "runtime/Runtime.h"
@@ -64,15 +63,11 @@ 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()
{
CustomEvent event;
event.name = EVENT_COME_TO_BACKGROUND;
EventDispatcher::dispatchCustomEvent(event);
EventDispatcher::dispatchEnterBackgroundEvent();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
CustomEvent event;
event.name = EVENT_COME_TO_FOREGROUND;
EventDispatcher::dispatchCustomEvent(event);
EventDispatcher::dispatchEnterForegroundEvent();
}