mirror of
https://github.com/cocos/cocos4.git
synced 2026-11-20 23:52:40 +08:00
a7f266b9e8
* start add menu back * simulator resume works * readded scale feature, fix exit bug * free SetupUI, and fix compile only * adapt to CustomEvent from struct to class * resume show/hide FPS feature * Revert "free SetupUI, and fix compile only" This reverts commit fd8cf5ca0a17ba62ae5dec46fefea3b58c267c9d. * Revert "Revert "free SetupUI, and fix compile only"" This reverts commit 6e5934a583db286508d00a61a22e11a3325090f1. * correct EXIT logic * scale works * show/hide fps works * remove unneed menu, replace tab with space * remove debug output info * no need _isShowFPS member * fix NSError init error
79 lines
2.9 KiB
C++
Executable File
79 lines
2.9 KiB
C++
Executable File
/****************************************************************************
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
|
|
|
http://www.cocos.com
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
of this software and associated engine source code (the "Software"), a limited,
|
|
worldwide, royalty-free, non-assignable, revocable and non-exclusive license
|
|
to use Cocos Creator solely to develop games on your target platforms. You shall
|
|
not use Cocos Creator software for developing other software or tools that's
|
|
used for developing games. You are not granted to publish, distribute,
|
|
sublicense, and/or sell copies of Cocos Creator.
|
|
|
|
The software or tools in this License Agreement are licensed, not sold.
|
|
Xiamen Yaji Software Co., Ltd. reserves all rights not expressly granted to you.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
THE SOFTWARE.
|
|
****************************************************************************/
|
|
|
|
#include "AppDelegate.h"
|
|
|
|
#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"
|
|
#include "ide-support/RuntimeJsImpl.h"
|
|
USING_NS_CC;
|
|
using namespace std;
|
|
|
|
AppDelegate::AppDelegate(const std::string& name, int width, int height) : Application(name, width, height)
|
|
{
|
|
}
|
|
|
|
AppDelegate::~AppDelegate()
|
|
{
|
|
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
|
|
RuntimeEngine::getInstance()->end();
|
|
}
|
|
|
|
bool AppDelegate::applicationDidFinishLaunching()
|
|
{
|
|
// set default FPS
|
|
Application::getInstance()->setPreferredFramesPerSecond(60);
|
|
|
|
auto runtimeEngine = RuntimeEngine::getInstance();
|
|
runtimeEngine->setEventTrackingEnable(true);
|
|
auto jsRuntime = RuntimeJsImpl::create();
|
|
runtimeEngine->addRuntime(jsRuntime, kRuntimeEngineJs);
|
|
runtimeEngine->start();
|
|
|
|
// Runtime end
|
|
cocos2d::log("iShow!");
|
|
return true;
|
|
}
|
|
|
|
// 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);
|
|
}
|
|
|
|
// 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);
|
|
}
|