项目能运行了, 能正确执行js

This commit is contained in:
cebgcontract 2022-06-29 11:49:31 +08:00
parent 7b09ffc364
commit 99eb6fed92
18 changed files with 55267 additions and 71 deletions

88
Classes/AppDelegate.cpp Executable file
View File

@ -0,0 +1,88 @@
/****************************************************************************
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/manual/jsb_module_register.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
#include "cocos/scripting/js-bindings/event/EventDispatcher.h"
#include "cocos/scripting/js-bindings/manual/jsb_classtype.hpp"
USING_NS_CC;
AppDelegate::AppDelegate(int width, int height) : Application("Cocos Game", width, height)
{
}
AppDelegate::~AppDelegate()
{
}
bool AppDelegate::applicationDidFinishLaunching()
{
se::ScriptEngine *se = se::ScriptEngine::getInstance();
jsb_set_xxtea_key("");
jsb_init_file_operation_delegate();
#if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0)
// Enable debugger here
jsb_enable_debugger("0.0.0.0", 6086, false);
#endif
se->setExceptionCallback([](const char *location, const char *message, const char *stack) {
// Send exception information to server like Tencent Bugly.
cocos2d::log("\nUncaught Exception:\n - location : %s\n - msg : %s\n - detail : \n %s\n", location, message, stack);
});
jsb_register_all_modules();
se->start();
se::AutoHandleScope hs;
jsb_run_script("js/jsb-adapter/jsb-builtin.js");
jsb_run_script("js/main.js");
se->addAfterCleanupHook([]() {
JSBClassType::destroy();
});
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::onPause()
{
EventDispatcher::dispatchOnPauseEvent();
}
// this function will be called when the app is active again
void AppDelegate::onResume()
{
EventDispatcher::dispatchOnResumeEvent();
}

55
Classes/AppDelegate.h Executable file
View File

@ -0,0 +1,55 @@
/****************************************************************************
Copyright (c) 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.
****************************************************************************/
#pragma once
#include "platform/CCApplication.h"
/**
@brief The cocos2d Application.
The reason for implement as private inheritance is to hide some interface call by Director.
*/
class AppDelegate : public cocos2d::Application
{
public:
AppDelegate(int width, int height);
virtual ~AppDelegate();
/**
@brief Implement Director and Scene init code here.
@return true Initialize success, app continue.
@return false Initialize failed, app terminate.
*/
virtual bool applicationDidFinishLaunching() override;
/**
@brief The function be called when the application is paused
*/
virtual void onPause() override;
/**
@brief The function be called when the application is resumed
*/
virtual void onResume() override;
};

31
Classes/NativeConfig.h Executable file
View File

@ -0,0 +1,31 @@
/****************************************************************************
Copyright (c) 2020 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.
****************************************************************************/
//window size for mac
#define MACOS_WIN_SIZE_WIDTH 960
#define MACOS_WIN_SIZE_HEIGHT 640
//window size for win32
#define WINDOWS_WIN_SIZE_WIDTH 960
#define WINDOWS_WIN_SIZE_HEIGHT 640

View File

@ -0,0 +1,194 @@
/****************************************************************************
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 "cocos2d.h"
#include "cocos/scripting/js-bindings/manual/jsb_module_register.hpp"
#include "cocos/scripting/js-bindings/jswrapper/SeApi.h"
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_global.h"
#include "cocos/scripting/js-bindings/manual/jsb_node.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_conversions.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_opengl_manual.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_platform.h"
#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_manual.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_xmlhttprequest.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_cocos2dx_network_manual.h"
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp"
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp"
#if USE_GFX_RENDERER
#include "cocos/scripting/js-bindings/auto/jsb_gfx_auto.hpp"
#include "cocos/scripting/js-bindings/auto/jsb_renderer_auto.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_gfx_manual.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_renderer_manual.hpp"
#endif
#if USE_SOCKET
#include "cocos/scripting/js-bindings/manual/jsb_websocket.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_socketio.hpp"
#if USE_WEBSOCKET_SERVER
#include "cocos/scripting/js-bindings/manual/jsb_websocket_server.hpp"
#endif
#endif // USE_SOCKET
#if USE_AUDIO
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include "cocos/scripting/js-bindings/manual/JavaScriptObjCBridge.h"
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "cocos/scripting/js-bindings/manual/JavaScriptJavaBridge.h"
#endif
#if USE_GFX_RENDERER && USE_MIDDLEWARE
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_editor_support_auto.hpp"
#if USE_SPINE
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_spine_manual.hpp"
#endif
#if USE_DRAGONBONES
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_dragonbones_auto.hpp"
#include "cocos/scripting/js-bindings/manual/jsb_dragonbones_manual.hpp"
#endif
#if USE_PARTICLE
#include "cocos/scripting/js-bindings/auto/jsb_cocos2dx_particle_auto.hpp"
#endif
#endif // USE_MIDDLEWARE
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if USE_VIDEO
#include "cocos/scripting/js-bindings/auto/jsb_video_auto.hpp"
#endif
#if USE_WEB_VIEW
#include "cocos/scripting/js-bindings/auto/jsb_webview_auto.hpp"
#endif
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
using namespace cocos2d;
bool jsb_register_all_modules()
{
se::ScriptEngine* se = se::ScriptEngine::getInstance();
se->addBeforeInitHook([](){
JSBClassType::init();
});
se->addBeforeCleanupHook([se](){
se->garbageCollect();
PoolManager::getInstance()->getCurrentPool()->clear();
se->garbageCollect();
PoolManager::getInstance()->getCurrentPool()->clear();
});
se->addRegisterCallback(jsb_register_global_variables);
se->addRegisterCallback(JSB_register_opengl);
se->addRegisterCallback(register_all_engine);
se->addRegisterCallback(register_all_cocos2dx_manual);
se->addRegisterCallback(register_platform_bindings);
se->addRegisterCallback(register_all_network);
se->addRegisterCallback(register_all_cocos2dx_network_manual);
se->addRegisterCallback(register_all_xmlhttprequest);
// extension depend on network
se->addRegisterCallback(register_all_extension);
#if USE_GFX_RENDERER
se->addRegisterCallback(register_all_gfx);
se->addRegisterCallback(jsb_register_gfx_manual);
se->addRegisterCallback(register_all_renderer);
se->addRegisterCallback(jsb_register_renderer_manual);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
se->addRegisterCallback(register_javascript_objc_bridge);
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
se->addRegisterCallback(register_javascript_java_bridge);
#endif
#if USE_AUDIO
se->addRegisterCallback(register_all_audioengine);
#endif
#if USE_SOCKET
se->addRegisterCallback(register_all_websocket);
se->addRegisterCallback(register_all_socketio);
#if USE_WEBSOCKET_SERVER
se->addRegisterCallback(register_all_websocket_server);
#endif
#endif
#if USE_GFX_RENDERER && USE_MIDDLEWARE
se->addRegisterCallback(register_all_cocos2dx_editor_support);
#if USE_SPINE
se->addRegisterCallback(register_all_cocos2dx_spine);
se->addRegisterCallback(register_all_spine_manual);
#endif
#if USE_DRAGONBONES
se->addRegisterCallback(register_all_cocos2dx_dragonbones);
se->addRegisterCallback(register_all_dragonbones_manual);
#endif
#if USE_PARTICLE
se->addRegisterCallback(register_all_cocos2dx_particle);
#endif
#endif // USE_MIDDLEWARE
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#if USE_VIDEO
se->addRegisterCallback(register_all_video);
#endif
#if USE_WEB_VIEW
se->addRegisterCallback(register_all_webview);
#endif
#endif // (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
se->addAfterCleanupHook([](){
PoolManager::getInstance()->getCurrentPool()->clear();
JSBClassType::destroy();
});
return true;
}

View File

@ -7,19 +7,44 @@
objects = {
/* Begin PBXBuildFile section */
D5AA8A0D286B029300E2C03E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A0C286B029300E2C03E /* AppDelegate.m */; };
D5AA8A10286B029300E2C03E /* SceneDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A0F286B029300E2C03E /* SceneDelegate.m */; };
D5AA8A13286B029300E2C03E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A12286B029300E2C03E /* ViewController.m */; };
D5AA8A16286B029300E2C03E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D5AA8A14286B029300E2C03E /* Main.storyboard */; };
D5AA8A18286B029700E2C03E /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D5AA8A17286B029700E2C03E /* Assets.xcassets */; };
D5AA8A1B286B029700E2C03E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D5AA8A19286B029700E2C03E /* LaunchScreen.storyboard */; };
D5AA8A1E286B029700E2C03E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A1D286B029700E2C03E /* main.m */; };
D5AA8A3B286B043200E2C03E /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A39286B043200E2C03E /* AppDelegate.cpp */; };
D5AA8A3D286B056D00E2C03E /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A2C286B033C00E2C03E /* libcocos2d iOS.a */; };
D5AA8A5D286B184000E2C03E /* libicucore.A.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A5C286B184000E2C03E /* libicucore.A.tbd */; };
D5AA8A64286B390F00E2C03E /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = D5AA8A62286B390E00E2C03E /* AppController.mm */; };
D5AA8A6B286B4AB900E2C03E /* JavaScriptCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A6A286B4AB900E2C03E /* JavaScriptCore.framework */; };
D5AA8A6D286B4B0A00E2C03E /* libsqlite3.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A6C286B4B0A00E2C03E /* libsqlite3.tbd */; };
D5AA8A6F286B4B3600E2C03E /* CFNetwork.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A6E286B4B3600E2C03E /* CFNetwork.framework */; };
D5AA8A74286BE42100E2C03E /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A71286BE42100E2C03E /* Security.framework */; };
D5AA8A76286BE4B100E2C03E /* libz.tbd in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A75286BE4B100E2C03E /* libz.tbd */; };
D5AA8A78286BE67D00E2C03E /* SystemConfiguration.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5AA8A77286BE67D00E2C03E /* SystemConfiguration.framework */; };
D5AA8A8C286BF94D00E2C03E /* js in Resources */ = {isa = PBXBuildFile; fileRef = D5AA8A8B286BF94D00E2C03E /* js */; };
/* End PBXBuildFile section */
/* Begin PBXContainerItemProxy section */
D5AA8A29286B033C00E2C03E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D5AA8A24286B033C00E2C03E /* cocos2d_libs.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = 1551A33F158F2AB200E66CFE;
remoteInfo = "libcocos2d Mac";
};
D5AA8A2B286B033C00E2C03E /* PBXContainerItemProxy */ = {
isa = PBXContainerItemProxy;
containerPortal = D5AA8A24286B033C00E2C03E /* cocos2d_libs.xcodeproj */;
proxyType = 2;
remoteGlobalIDString = A07A4D641783777C0073F6A7;
remoteInfo = "libcocos2d iOS";
};
/* End PBXContainerItemProxy section */
/* Begin PBXFileReference section */
D5AA8A08286B029300E2C03E /* HeadlessCocos.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = HeadlessCocos.app; sourceTree = BUILT_PRODUCTS_DIR; };
D5AA8A0B286B029300E2C03E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
D5AA8A0C286B029300E2C03E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = "<group>"; };
D5AA8A0E286B029300E2C03E /* SceneDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SceneDelegate.h; sourceTree = "<group>"; };
D5AA8A0F286B029300E2C03E /* SceneDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = SceneDelegate.m; sourceTree = "<group>"; };
D5AA8A11286B029300E2C03E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = "<group>"; };
@ -29,6 +54,21 @@
D5AA8A1A286B029700E2C03E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
D5AA8A1C286B029700E2C03E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
D5AA8A1D286B029700E2C03E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = "<group>"; };
D5AA8A24286B033C00E2C03E /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = "../../cocos/cocos2d-x/build/cocos2d_libs.xcodeproj"; sourceTree = "<group>"; };
D5AA8A36286B043200E2C03E /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = "<group>"; };
D5AA8A38286B043200E2C03E /* NativeConfig.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NativeConfig.h; sourceTree = "<group>"; };
D5AA8A39286B043200E2C03E /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = "<group>"; };
D5AA8A54286B15D500E2C03E /* libc++.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = "libc++.tbd"; path = "usr/lib/libc++.tbd"; sourceTree = SDKROOT; };
D5AA8A5C286B184000E2C03E /* libicucore.A.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libicucore.A.tbd; path = usr/lib/libicucore.A.tbd; sourceTree = SDKROOT; };
D5AA8A62286B390E00E2C03E /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = AppController.mm; sourceTree = "<group>"; };
D5AA8A63286B390F00E2C03E /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppController.h; sourceTree = "<group>"; };
D5AA8A6A286B4AB900E2C03E /* JavaScriptCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = JavaScriptCore.framework; path = System/Library/Frameworks/JavaScriptCore.framework; sourceTree = SDKROOT; };
D5AA8A6C286B4B0A00E2C03E /* libsqlite3.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libsqlite3.tbd; path = usr/lib/libsqlite3.tbd; sourceTree = SDKROOT; };
D5AA8A6E286B4B3600E2C03E /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = System/Library/Frameworks/CFNetwork.framework; sourceTree = SDKROOT; };
D5AA8A71286BE42100E2C03E /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; };
D5AA8A75286BE4B100E2C03E /* libz.tbd */ = {isa = PBXFileReference; lastKnownFileType = "sourcecode.text-based-dylib-definition"; name = libz.tbd; path = usr/lib/libz.tbd; sourceTree = SDKROOT; };
D5AA8A77286BE67D00E2C03E /* SystemConfiguration.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = SystemConfiguration.framework; path = System/Library/Frameworks/SystemConfiguration.framework; sourceTree = SDKROOT; };
D5AA8A8B286BF94D00E2C03E /* js */ = {isa = PBXFileReference; lastKnownFileType = folder; path = js; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@ -36,6 +76,14 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D5AA8A78286BE67D00E2C03E /* SystemConfiguration.framework in Frameworks */,
D5AA8A76286BE4B100E2C03E /* libz.tbd in Frameworks */,
D5AA8A74286BE42100E2C03E /* Security.framework in Frameworks */,
D5AA8A6F286B4B3600E2C03E /* CFNetwork.framework in Frameworks */,
D5AA8A6D286B4B0A00E2C03E /* libsqlite3.tbd in Frameworks */,
D5AA8A6B286B4AB900E2C03E /* JavaScriptCore.framework in Frameworks */,
D5AA8A5D286B184000E2C03E /* libicucore.A.tbd in Frameworks */,
D5AA8A3D286B056D00E2C03E /* libcocos2d iOS.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -45,8 +93,11 @@
D5AA89FF286B029200E2C03E = {
isa = PBXGroup;
children = (
D5AA8A35286B043200E2C03E /* Classes */,
D5AA8A24286B033C00E2C03E /* cocos2d_libs.xcodeproj */,
D5AA8A0A286B029300E2C03E /* HeadlessCocos */,
D5AA8A09286B029300E2C03E /* Products */,
D5AA8A3C286B056D00E2C03E /* Frameworks */,
);
sourceTree = "<group>";
};
@ -61,12 +112,13 @@
D5AA8A0A286B029300E2C03E /* HeadlessCocos */ = {
isa = PBXGroup;
children = (
D5AA8A0B286B029300E2C03E /* AppDelegate.h */,
D5AA8A0C286B029300E2C03E /* AppDelegate.m */,
D5AA8A12286B029300E2C03E /* ViewController.m */,
D5AA8A63286B390F00E2C03E /* AppController.h */,
D5AA8A62286B390E00E2C03E /* AppController.mm */,
D5AA8A8B286BF94D00E2C03E /* js */,
D5AA8A0E286B029300E2C03E /* SceneDelegate.h */,
D5AA8A0F286B029300E2C03E /* SceneDelegate.m */,
D5AA8A11286B029300E2C03E /* ViewController.h */,
D5AA8A12286B029300E2C03E /* ViewController.m */,
D5AA8A14286B029300E2C03E /* Main.storyboard */,
D5AA8A17286B029700E2C03E /* Assets.xcassets */,
D5AA8A19286B029700E2C03E /* LaunchScreen.storyboard */,
@ -76,6 +128,40 @@
path = HeadlessCocos;
sourceTree = "<group>";
};
D5AA8A25286B033C00E2C03E /* Products */ = {
isa = PBXGroup;
children = (
D5AA8A2A286B033C00E2C03E /* libcocos2d Mac.a */,
D5AA8A2C286B033C00E2C03E /* libcocos2d iOS.a */,
);
name = Products;
sourceTree = "<group>";
};
D5AA8A35286B043200E2C03E /* Classes */ = {
isa = PBXGroup;
children = (
D5AA8A36286B043200E2C03E /* AppDelegate.h */,
D5AA8A39286B043200E2C03E /* AppDelegate.cpp */,
D5AA8A38286B043200E2C03E /* NativeConfig.h */,
);
path = Classes;
sourceTree = "<group>";
};
D5AA8A3C286B056D00E2C03E /* Frameworks */ = {
isa = PBXGroup;
children = (
D5AA8A77286BE67D00E2C03E /* SystemConfiguration.framework */,
D5AA8A75286BE4B100E2C03E /* libz.tbd */,
D5AA8A71286BE42100E2C03E /* Security.framework */,
D5AA8A6E286B4B3600E2C03E /* CFNetwork.framework */,
D5AA8A6C286B4B0A00E2C03E /* libsqlite3.tbd */,
D5AA8A6A286B4AB900E2C03E /* JavaScriptCore.framework */,
D5AA8A5C286B184000E2C03E /* libicucore.A.tbd */,
D5AA8A54286B15D500E2C03E /* libc++.tbd */,
);
name = Frameworks;
sourceTree = "<group>";
};
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@ -121,6 +207,12 @@
mainGroup = D5AA89FF286B029200E2C03E;
productRefGroup = D5AA8A09286B029300E2C03E /* Products */;
projectDirPath = "";
projectReferences = (
{
ProductGroup = D5AA8A25286B033C00E2C03E /* Products */;
ProjectRef = D5AA8A24286B033C00E2C03E /* cocos2d_libs.xcodeproj */;
},
);
projectRoot = "";
targets = (
D5AA8A07286B029300E2C03E /* HeadlessCocos */,
@ -128,6 +220,23 @@
};
/* End PBXProject section */
/* Begin PBXReferenceProxy section */
D5AA8A2A286B033C00E2C03E /* libcocos2d Mac.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libcocos2d Mac.a";
remoteRef = D5AA8A29286B033C00E2C03E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
D5AA8A2C286B033C00E2C03E /* libcocos2d iOS.a */ = {
isa = PBXReferenceProxy;
fileType = archive.ar;
path = "libcocos2d iOS.a";
remoteRef = D5AA8A2B286B033C00E2C03E /* PBXContainerItemProxy */;
sourceTree = BUILT_PRODUCTS_DIR;
};
/* End PBXReferenceProxy section */
/* Begin PBXResourcesBuildPhase section */
D5AA8A06286B029300E2C03E /* Resources */ = {
isa = PBXResourcesBuildPhase;
@ -136,6 +245,7 @@
D5AA8A1B286B029700E2C03E /* LaunchScreen.storyboard in Resources */,
D5AA8A18286B029700E2C03E /* Assets.xcassets in Resources */,
D5AA8A16286B029300E2C03E /* Main.storyboard in Resources */,
D5AA8A8C286BF94D00E2C03E /* js in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -147,9 +257,10 @@
buildActionMask = 2147483647;
files = (
D5AA8A13286B029300E2C03E /* ViewController.m in Sources */,
D5AA8A0D286B029300E2C03E /* AppDelegate.m in Sources */,
D5AA8A3B286B043200E2C03E /* AppDelegate.cpp in Sources */,
D5AA8A1E286B029700E2C03E /* main.m in Sources */,
D5AA8A10286B029300E2C03E /* SceneDelegate.m in Sources */,
D5AA8A64286B390F00E2C03E /* AppController.mm in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -178,7 +289,7 @@
D5AA8A1F286B029700E2C03E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ALWAYS_SEARCH_USER_PATHS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
@ -231,13 +342,33 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = (
"/Users/zhl/Documents/workspace/cocos/cocos2d-x",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/base",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/physics",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/math/kazmath",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/2d",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/gui",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/network",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/audio/include",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/editor-support",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/extensions",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/sources",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/chipmunk/include/chipmunk",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/v8",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/scripting/js-bindings/auto",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/scripting/js-bindings/manual",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/renderer",
);
};
name = Debug;
};
D5AA8A20286B029700E2C03E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
ALWAYS_SEARCH_USER_PATHS = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++17";
@ -283,6 +414,26 @@
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
SDKROOT = iphoneos;
USER_HEADER_SEARCH_PATHS = (
"/Users/zhl/Documents/workspace/cocos/cocos2d-x",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/base",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/physics",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/math/kazmath",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/2d",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/gui",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/network",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/audio/include",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/editor-support",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/extensions",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/sources",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/chipmunk/include/chipmunk",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/v8",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/scripting/js-bindings/auto",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/scripting/js-bindings/manual",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/renderer",
);
VALIDATE_PRODUCT = YES;
};
name = Release;
@ -290,12 +441,15 @@
D5AA8A22286B029700E2C03E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_OBJC_ARC = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8TB4N4YTJ3;
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = HeadlessCocos/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
@ -306,23 +460,38 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/ios/libs";
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"-ObjC",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.zhl.HeadlessCocos;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = (
"$(inherited)",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/platform/mac",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/glfw3/include/mac",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/spidermonkey",
);
};
name = Debug;
};
D5AA8A23286B029700E2C03E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = YES;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CLANG_ENABLE_OBJC_ARC = NO;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_TEAM = 8TB4N4YTJ3;
GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "";
INFOPLIST_FILE = HeadlessCocos/Info.plist;
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
@ -333,11 +502,23 @@
"$(inherited)",
"@executable_path/Frameworks",
);
LIBRARY_SEARCH_PATHS = "/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/ios/libs";
MARKETING_VERSION = 1.0;
OTHER_LDFLAGS = (
"-ObjC",
"$(inherited)",
);
PRODUCT_BUNDLE_IDENTIFIER = com.zhl.HeadlessCocos;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_EMIT_LOC_STRINGS = YES;
TARGETED_DEVICE_FAMILY = "1,2";
USER_HEADER_SEARCH_PATHS = (
"$(inherited)",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/cocos/platform/mac",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/glfw3/include/mac",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/",
"/Users/zhl/Documents/workspace/cocos/cocos2d-x/external/mac/include/spidermonkey",
);
};
name = Release;
};

View File

@ -0,0 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array/>
</plist>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<Bucket
uuid = "30022AB3-3C65-4AFD-8DA6-2FBF3887D4CF"
type = "1"
version = "2.0">
<Breakpoints>
<BreakpointProxy
BreakpointExtensionID = "Xcode.Breakpoint.FileBreakpoint">
<BreakpointContent
uuid = "F93B7888-2E90-47B2-AF79-5C8AE02C3398"
shouldBeEnabled = "No"
ignoreCount = "0"
continueAfterRunningActions = "No"
filePath = "Classes/AppDelegate.cpp"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
startingLineNumber = "63"
endingLineNumber = "63"
landmarkName = "AppDelegate::applicationDidFinishLaunching()"
landmarkType = "7">
</BreakpointContent>
</BreakpointProxy>
</Breakpoints>
</Bucket>

View File

@ -7,7 +7,7 @@
<key>HeadlessCocos.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
<integer>1</integer>
</dict>
</dict>
</dict>

37
HeadlessCocos/AppController.h Executable file
View File

@ -0,0 +1,37 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
****************************************************************************/
#import <UIKit/UIKit.h>
@class ViewController;
@interface AppController : NSObject <UIApplicationDelegate>
{
}
@property(nonatomic, readonly) ViewController* viewController;
@end

137
HeadlessCocos/AppController.mm Executable file
View File

@ -0,0 +1,137 @@
/****************************************************************************
Copyright (c) 2010-2013 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
http://www.cocos2d-x.org
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
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.
****************************************************************************/
#import "AppController.h"
#import "cocos2d.h"
#import "AppDelegate.h"
#import "ViewController.h"
//#import "SDKWrapper.h"
#import "platform/ios/CCEAGLView-ios.h"
using namespace cocos2d;
@implementation AppController
Application* app = nullptr;
@synthesize window;
#pragma mark -
#pragma mark Application lifecycle
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// [[SDKWrapper getInstance] application:application didFinishLaunchingWithOptions:launchOptions];
// Add the view controller's view to the window and display.
float scale = [[UIScreen mainScreen] scale];
CGRect bounds = [[UIScreen mainScreen] bounds];
window = [[UIWindow alloc] initWithFrame: bounds];
// cocos2d application instance
app = new AppDelegate(bounds.size.width * scale, bounds.size.height * scale);
app->setMultitouch(true);
// Use RootViewController to manage CCEAGLView
_viewController = [[ViewController alloc]init];
#ifdef NSFoundationVersionNumber_iOS_7_0
_viewController.automaticallyAdjustsScrollViewInsets = NO;
_viewController.extendedLayoutIncludesOpaqueBars = NO;
_viewController.edgesForExtendedLayout = UIRectEdgeAll;
#else
_viewController.wantsFullScreenLayout = YES;
#endif
// Set RootViewController to window
if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0)
{
// warning: addSubView doesn't work on iOS6
[window addSubview: _viewController.view];
}
else
{
// use this method on ios6
[window setRootViewController:_viewController];
}
[window makeKeyAndVisible];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
//run the cocos2d-x game scene
app->start();
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application {
/*
Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
*/
app->onPause();
// [[SDKWrapper getInstance] applicationWillResignActive:application];
}
- (void)applicationDidBecomeActive:(UIApplication *)application {
/*
Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
*/
app->onResume();
// [[SDKWrapper getInstance] applicationDidBecomeActive:application];
}
- (void)applicationDidEnterBackground:(UIApplication *)application {
/*
Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
If your application supports background execution, called instead of applicationWillTerminate: when the user quits.
*/
// [[SDKWrapper getInstance] applicationDidEnterBackground:application];
}
- (void)applicationWillEnterForeground:(UIApplication *)application {
/*
Called as part of transition from the background to the inactive state: here you can undo many of the changes made on entering the background.
*/
// [[SDKWrapper getInstance] applicationWillEnterForeground:application];
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// [[SDKWrapper getInstance] applicationWillTerminate:application];
delete app;
app = nil;
}
#pragma mark -
#pragma mark Memory management
- (void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
/*
Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later.
*/
}
@end

View File

@ -1,14 +0,0 @@
//
// AppDelegate.h
// HeadlessCocos
//
// Created by zhl on 2022/6/28.
//
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@end

View File

@ -1,40 +0,0 @@
//
// AppDelegate.m
// HeadlessCocos
//
// Created by zhl on 2022/6/28.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
return YES;
}
#pragma mark - UISceneSession lifecycle
- (UISceneConfiguration *)application:(UIApplication *)application configurationForConnectingSceneSession:(UISceneSession *)connectingSceneSession options:(UISceneConnectionOptions *)options {
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return [[UISceneConfiguration alloc] initWithName:@"Default Configuration" sessionRole:connectingSceneSession.role];
}
- (void)application:(UIApplication *)application didDiscardSceneSessions:(NSSet<UISceneSession *> *)sceneSessions {
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
@end

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

42858
HeadlessCocos/js/jsb-adapter/web3.min.js vendored Normal file

File diff suppressed because one or more lines are too long

10
HeadlessCocos/js/main.js Normal file
View File

@ -0,0 +1,10 @@
require('js/jsb-adapter/web3.min.js');
console.log('hi tiny cocos')
var web3 = new Web3('https://rpc-testnet.kcc.network')
// let key = '0xa6c4354fb93a55fb67117969a12465209395ec31089fea9e6e061f873b87a473'
// web3.eth.accounts.wallet.add(key);
// web3.eth.accounts.wallet.save('111111')
window.wallet = web3.eth.accounts.wallet.load('111111')
console.log(web3.eth.accounts.wallet[0].address);
console.log(web3.eth.accounts.wallet[0].privateKey);
console.log('end of main.js')

View File

@ -6,13 +6,10 @@
//
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
int main(int argc, char * argv[]) {
NSString * appDelegateClassName;
@autoreleasepool {
// Setup code that might create autoreleased objects goes here.
appDelegateClassName = NSStringFromClass([AppDelegate class]);
}
return UIApplicationMain(argc, argv, nil, appDelegateClassName);
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, @"AppController");
[pool release];
return retVal;
}

44
README.md Normal file
View File

@ -0,0 +1,44 @@
该项目用于测试空项目接入 剥离了webgl的cocos jsb代码
1. 将native项目的class文件夹复制入项目
2. 将cocos2d-x/build/cocos2d_libs.xcodeproj拖进xcode中的项目中
3. 修改 projectname.xcodeproj/project.pbxproj, 搜索USER_HEADER_SEARCH_PATHS, 将如下内容加入
```
"$(inherited)",
"/pathOfCocos/cocos2d-x/cocos",
"/pathOfCocos/cocos2d-x/cocos/platform/ios",
"/pathOfCocos/cocos2d-x/plugin/jsbindings/auto",
"/pathOfCocos/cocos2d-x/plugin/jsbindings/manual",
"/pathOfCocos/cocos2d-x/external/ios/include",
"/pathOfCocos/cocos2d-x/external/ios/include/spidermonkey",
```
同时加入如下内容:
```
LIBRARY_SEARCH_PATHS = "/pathOfCocos/cocos2d-x/external/ios/libs";
```
4. 在project的build setting -> search paths -> user header search paths 加入如下内容
```
/pathOfCocos/cocos/cocos2d-x /pathOfCocos/cocos/cocos2d-x/cocos /pathOfCocos/cocos/cocos2d-x/cocos/base /pathOfCocos/cocos/cocos2d-x/cocos/physics /pathOfCocos/cocos/cocos2d-x/cocos/math/kazmath /pathOfCocos/cocos/cocos2d-x/cocos/2d /pathOfCocos/cocos/cocos2d-x/cocos/gui /pathOfCocos/cocos/cocos2d-x/cocos/network /pathOfCocos/cocos/cocos2d-x/cocos/audio/include /pathOfCocos/cocos/cocos2d-x/cocos/editor-support /pathOfCocos/cocos/cocos2d-x/extensions /pathOfCocos/cocos/cocos2d-x/external /pathOfCocos/cocos/cocos2d-x/external/sources /pathOfCocos/cocos/cocos2d-x/external/chipmunk/include/chipmunk /pathOfCocos/cocos/cocos2d-x/external/mac/include/v8 /pathOfCocos/cocos/cocos2d-x/cocos/scripting/js-bindings/auto /pathOfCocos/cocos/cocos2d-x/cocos/scripting/js-bindings/manual /pathOfCocos/cocos/cocos2d-x/cocos/renderer
```
5. Build Phases-> Link Biny With Libraries 添加如下Library
```
libicucore.A.tbd
libsqlite3.tbd
Security.framework
CFNetwork.framework
JavaScriptCore.framework
libz.tbd
SystemConfiguration.framework
```
6. 将jsb-adapter/jsb-builtin.js中有关webgl的代码删除, 并将相关js拖入项目, 拖入时, 选择'Create folder reference'