├── .cocos-project.json ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── frameworks ├── cocos2d-html5 │ └── README.md ├── cocos2d-x │ └── README.md └── runtime-src │ ├── Classes │ ├── AppDelegate.cpp │ ├── AppDelegate.h │ ├── JSBH.h │ └── JSBH.mm │ ├── proj.android-studio │ ├── .gitignore │ ├── app │ │ ├── .gitignore │ │ ├── AndroidManifest.xml │ │ ├── build.gradle │ │ ├── get_environment.sh │ │ ├── jni │ │ │ ├── Android.mk │ │ │ ├── Application.mk │ │ │ └── hellojavascript │ │ │ │ └── main.cpp │ │ ├── proguard-rules.pro │ │ ├── res │ │ │ ├── mipmap-hdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-mdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xhdpi │ │ │ │ └── ic_launcher.png │ │ │ ├── mipmap-xxhdpi │ │ │ │ └── ic_launcher.png │ │ │ └── values │ │ │ │ └── strings.xml │ │ └── src │ │ │ └── org │ │ │ └── cocos2dx │ │ │ └── javascript │ │ │ └── AppActivity.java │ ├── build.gradle │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.properties │ ├── gradlew │ ├── gradlew.bat │ └── settings.gradle │ ├── proj.android │ ├── .classpath │ ├── .project │ ├── .settings │ │ └── org.eclipse.jdt.core.prefs │ ├── AndroidManifest.xml │ ├── README.md │ ├── ant.properties │ ├── build-cfg.json │ ├── build.xml │ ├── jni │ │ ├── Android.mk │ │ ├── Application.mk │ │ └── hellojavascript │ │ │ └── main.cpp │ ├── proguard-project.txt │ ├── project.properties │ ├── res │ │ ├── drawable-hdpi │ │ │ └── icon.png │ │ ├── drawable-ldpi │ │ │ └── icon.png │ │ ├── drawable-mdpi │ │ │ └── icon.png │ │ └── values │ │ │ └── strings.xml │ └── src │ │ └── org │ │ └── cocos2dx │ │ └── javascript │ │ └── AppActivity.java │ ├── proj.ios_mac │ ├── iOSBinding.h │ ├── iOSBinding.mm │ ├── iOSBindingInterface.js │ ├── iOS_JSB.xcodeproj │ │ ├── project.pbxproj │ │ └── project.xcworkspace │ │ │ └── contents.xcworkspacedata │ ├── ios │ │ ├── AppController.h │ │ ├── AppController.mm │ │ ├── Default-568h@2x.png │ │ ├── Default-736h@3x.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default.png │ │ ├── Default@2x.png │ │ ├── Icon-100.png │ │ ├── Icon-114.png │ │ ├── Icon-120.png │ │ ├── Icon-144.png │ │ ├── Icon-152.png │ │ ├── Icon-180.png │ │ ├── Icon-29.png │ │ ├── Icon-40.png │ │ ├── Icon-50.png │ │ ├── Icon-57.png │ │ ├── Icon-58.png │ │ ├── Icon-72.png │ │ ├── Icon-76.png │ │ ├── Icon-80.png │ │ ├── Icon-87.png │ │ ├── Info.plist │ │ ├── Prefix.pch │ │ ├── RootViewController.h │ │ ├── RootViewController.mm │ │ └── main.m │ └── mac │ │ ├── Icon.icns │ │ ├── Info.plist │ │ ├── Prefix.pch │ │ └── main.cpp │ ├── proj.linux │ └── main.cpp │ └── proj.win32 │ ├── build-cfg.json │ ├── game.rc │ ├── iOS_JSB.sln │ ├── iOS_JSB.vcxproj │ ├── iOS_JSB.vcxproj.filters │ ├── iOS_JSB.vcxproj.user │ ├── main.cpp │ ├── main.h │ ├── res │ └── game.ico │ └── resource.h ├── index.html ├── main.js ├── manifest.webapp ├── project.json ├── res ├── HelloWorld.png └── loading.js └── src ├── app.js └── resource.js /.cocos-project.json: -------------------------------------------------------------------------------- 1 | { 2 | "engine_version": "cocos2d-x-3.16", 3 | "has_native": true, 4 | "project_type": "js" 5 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Build generated 2 | build/ 3 | DerivedData/ 4 | 5 | ## Various settings 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | 16 | ## Other 17 | *.moved-aside 18 | *.xccheckout 19 | *.xcscmblueprint 20 | 21 | ## Obj-C/Swift specific 22 | *.hmap 23 | *.ipa 24 | *.dSYM.zip 25 | *.dSYM 26 | 27 | # CocoaPods 28 | # 29 | # We recommend against adding the Pods directory to your .gitignore. However 30 | # you should judge for yourself, the pros and cons are mentioned at: 31 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 32 | # 33 | # Pods/ 34 | 35 | # Carthage 36 | # 37 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 38 | # Carthage/Checkouts 39 | 40 | Carthage/Build 41 | 42 | # fastlane 43 | # 44 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 45 | # screenshots whenever they are needed. 46 | # For more information about the recommended setup visit: 47 | # https://docs.fastlane.tools/best-practices/source-control/#source-control 48 | 49 | fastlane/report.xml 50 | fastlane/Preview.html 51 | fastlane/screenshots 52 | fastlane/test_output 53 | 54 | # Code Injection 55 | # 56 | # After new code Injection tools there's a generated folder /iOSInjectionProject 57 | # https://github.com/johnno1962/injectionforxcode 58 | 59 | iOSInjectionProject/ 60 | 61 | # Engine 62 | frameworks/cocos2d-html5/ 63 | frameworks/cocos2d-x/ 64 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #/**************************************************************************** 2 | # Copyright (c) 2013 cocos2d-x.org 3 | # Copyright (c) 2014 martell malone 4 | # Copyright (c) 2015-2017 Chukong Technologies Inc. 5 | # 6 | # http://www.cocos2d-x.org 7 | # 8 | # Permission is hereby granted, free of charge, to any person obtaining a copy 9 | # of this software and associated documentation files (the "Software"), to deal 10 | # in the Software without restriction, including without limitation the rights 11 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | # copies of the Software, and to permit persons to whom the Software is 13 | # furnished to do so, subject to the following conditions: 14 | 15 | # The above copyright notice and this permission notice shall be included in 16 | # all copies or substantial portions of the Software. 17 | 18 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | # THE SOFTWARE. 25 | # ****************************************************************************/ 26 | 27 | cmake_minimum_required(VERSION 3.1) 28 | # It ensures that when Find*.cmake files included from cmake's Modules dir 29 | # include another *.cmake file with relative path, that file will be included 30 | # also from cmake's Modules dir, to not clash with per-project files. 31 | cmake_policy(SET CMP0017 NEW) 32 | 33 | # Use new behaviour with cmake >= 3.1: 34 | # Only interpret if() arguments as variables or keywords when unquoted. 35 | if(CMAKE_VERSION VERSION_GREATER 3.1) 36 | cmake_policy(SET CMP0054 NEW) 37 | endif() 38 | 39 | set(APP_NAME MyGame) 40 | project (${APP_NAME}) 41 | 42 | # define some variables 43 | set(COCOS2D_X_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/cocos2d-x) 44 | set(RUNTIME_SRC_ROOT ${CMAKE_CURRENT_SOURCE_DIR}/frameworks/runtime-src) 45 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${COCOS2D_X_ROOT}/cmake/Modules/") 46 | set(COCOS_EXTERNAL_DIR ${COCOS2D_X_ROOT}/external) 47 | # architecture 48 | if (CMAKE_SIZEOF_VOID_P EQUAL 8) 49 | set(ARCH_DIR "64-bit") 50 | elseif (CMAKE_SIZEOF_VOID_P EQUAL 4) 51 | set(ARCH_DIR "32-bit") 52 | else() 53 | message(FATAL_ERROR "Unsupported architecture, CMake will exit") 54 | return() 55 | endif() 56 | # CMAKE_BUILD_TYPE has precedence over DEBUG_MODE 57 | # Still supporting DEBUG_MODE for backwards compatibility 58 | if (NOT CMAKE_BUILD_TYPE) 59 | if(DEBUG_MODE) 60 | set(CMAKE_BUILD_TYPE DEBUG) 61 | else(DEBUG_MODE) 62 | set(CMAKE_BUILD_TYPE RELEASE) 63 | endif(DEBUG_MODE) 64 | endif(NOT CMAKE_BUILD_TYPE) 65 | 66 | include(CocosBuildHelpers) 67 | 68 | message(${BUILDING_STRING}) 69 | 70 | # SelectModule() is a macro to select building modules 71 | include(SelectModule) 72 | SelectModule() 73 | 74 | # set compiler options 75 | include(SetCompilerOptions) 76 | SetCompilerOptions() 77 | 78 | if (CMAKE_FIND_ROOT_PATH AND USE_PREBUILT_LIBS) 79 | # Adds cocos2d-x external folder to the list of valid include/library paths when cross-compiling and using prebuilds 80 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${COCOS_EXTERNAL_DIR}) 81 | endif () 82 | 83 | include_directories( 84 | ${COCOS2D_X_ROOT} 85 | ${COCOS2D_X_ROOT}/cocos 86 | ${COCOS2D_X_ROOT}/deprecated 87 | ${COCOS2D_X_ROOT}/cocos/platform 88 | ${COCOS2D_X_ROOT}/extensions 89 | ${COCOS2D_X_ROOT}/external 90 | ${COCOS2D_X_ROOT}/external/spidermonkey/include/${PLATFORM_FOLDER} 91 | ${COCOS2D_X_ROOT}/cocos/editor-support 92 | ) 93 | 94 | if(USE_PREBUILT_LIBS) 95 | include(CocosUsePrebuiltLibs) 96 | endif() 97 | 98 | set(PREV_CMAKE_CURRENT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) 99 | set(CMAKE_CURRENT_SOURCE_DIR ${COCOS2D_X_ROOT}) 100 | include(BuildModules) 101 | BuildModules() 102 | set(CMAKE_CURRENT_SOURCE_DIR ${PREV_CMAKE_CURRENT_SOURCE_DIR}) 103 | 104 | if(WIN32) 105 | else() 106 | set(GAME_SRC 107 | ${RUNTIME_SRC_ROOT}/proj.linux/main.cpp 108 | ${RUNTIME_SRC_ROOT}/Classes/AppDelegate.cpp 109 | ) 110 | endif() 111 | 112 | 113 | # jsbinding library 114 | add_subdirectory(${COCOS2D_X_ROOT}/cocos/scripting/js-bindings) 115 | 116 | add_executable(${APP_NAME} 117 | ${GAME_SRC} 118 | ) 119 | 120 | target_link_libraries(${APP_NAME} 121 | jscocos2d 122 | cocos2d 123 | ) 124 | 125 | set(APP_BIN_DIR "${CMAKE_BINARY_DIR}/bin") 126 | 127 | set_target_properties(${APP_NAME} PROPERTIES 128 | RUNTIME_OUTPUT_DIRECTORY "${APP_BIN_DIR}") 129 | 130 | if(LINUX) 131 | set(RES_PREFIX "/Resources") 132 | else() 133 | set(RES_PREFIX "") 134 | endif() 135 | 136 | pre_build(${APP_NAME} 137 | COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/script 138 | COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/res 139 | COMMAND ${CMAKE_COMMAND} -E remove_directory ${APP_BIN_DIR}${RES_PREFIX}/src 140 | COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}${RES_PREFIX}/*.js 141 | COMMAND ${CMAKE_COMMAND} -E remove ${APP_BIN_DIR}${RES_PREFIX}/*.json 142 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/Resources ${APP_BIN_DIR}${RES_PREFIX}/res 143 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/res ${APP_BIN_DIR}${RES_PREFIX}/res 144 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${APP_BIN_DIR}${RES_PREFIX}/src 145 | COMMAND ${CMAKE_COMMAND} -E copy_directory ${COCOS2D_X_ROOT}/cocos/scripting/js-bindings/script ${APP_BIN_DIR}${RES_PREFIX}/script 146 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/main.js ${APP_BIN_DIR}${RES_PREFIX}/main.js 147 | COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/project.json ${APP_BIN_DIR}${RES_PREFIX}/project.json 148 | ) 149 | 150 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Cocos2d-x js-binding Demo (iOS) 2 | 3 | 珍爱生命,远离 Cocos2D。 4 | 5 | 吐槽在最后,直接看如何用。在 Cocos2d 项目中,JS 与 native 间相互调用有三种方法: 6 | 7 | 1. [JS 通过 jsb.reflection 调用 native 方法](#reflection) 8 | 2. [Native 通过 ScriptingCore 执行 JS 代码](#scriptingcore) 9 | 3. [Native 通过 JSB 把注入方法到 JS 环境,供 JS 调用](#jsb) 10 | 11 | 在简要介绍完这三种方法后,是对 demo 的一些说明。 12 | 13 | ## 使用 jsb.reflection 14 | 15 | 在 JS 中形如: 16 | 17 | ```js 18 | var returnValue = jsb.reflection.callStaticMethod("ObjectiveCClass", "methodWithParameter:", aParameter); 19 | ``` 20 | 21 | 调用 Android 方法还要多一个方法签名的参数。使用方法不多说,这部分官方文档还是能看的。 22 | 23 | * [How to call Objective-C functions using JavaScript on iOS/Mac](http://www.cocos2d-x.org/docs/creator/en/advanced-topics/oc-reflection.html) 24 | * [How to Call Java methods using JavaScript on Android](http://www.cocos2d-x.org/docs/creator/en/advanced-topics/java-reflection.html) 25 | 26 | 但是,不推荐大规模用这种方法,因为不同平台代码无法统一会显得繁杂,而且限制比较多,只能调用静态的、同步的方法。 27 | 28 | ## Native 通过 ScriptingCore 执行 JS 代码 29 | 30 | ScriptingCore 实例有 evalString 方法,可以传入 JS 字符串执行相应代码。如 31 | 32 | ```cpp 33 | ScriptingCore::getInstance()->evalString("console.log('Hello word!')"); 34 | ``` 35 | 36 | 如果要接收返回值,稍微麻烦一点,见 [JSBH_EvalJSStringReturnString()](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/f78d5dc16bd0c8a5664fc435231b78e9d480d45a/frameworks/runtime-src/Classes/JSBH.mm#L45)。 37 | 38 | ScriptingCore 除了 eval 之外,还有其它像 executeFunctionWithOwner 这样的方法,但是大都要求有一定的上下文,一般在下面提到的 JSB 注入中才能用到。 39 | 40 | eval is evil,简单但尽量避免使用。不得不用时注意不要频繁调用,不要拼接来自用户、第三方的输入,保持简单。 41 | 42 | ## Native JSB 注入 43 | 44 | 相较上面两种方式,JSB 注入就强大多了(相应也更复杂),Cocos2d-x 引擎是 C++ 写的,能被 JS 调用靠的就是 JSB。 45 | 46 | Cosos2d 中 JSB 有两种方式:auto、manual。网上搜 cocos2d js binding 可以搜到大把的文章,要么告诉你用官方的脚本自动绑定,要么贴出大段不知从那儿来 copy 来的代码手动完成绑定。 47 | 48 | 官方的自动绑定脚本在引擎目录下 [tools/tojs/genbindings.py](https://github.com/cocos2d/cocos2d-x/tree/v3/tools/tojs),但是不建议去用。使用它你需要下载 Android NDK,下载 python 依赖,编写一个 ini 文件。你需要足够的耐心才能搞明白这个工具怎么用,然后足够幸运让这个脆弱的脚本成功输出得到一堆看上去比较复杂的东西。还有,路径中别有空格和符号哦。 49 | 50 | 打开 AppDelegate.cpp,你会看到这里通过 ScriptingCore 的 addRegisterCallback 注册了引擎的各种方法,参数都是一个 C 函数。点进去看大都一排排的代码长得都差不多。然后怎么写、怎么用?官方有个 [The Tutorial for JSB 2.0](http://www.cocos2d-x.org/docs/creator/en/advanced-topics/jsb/JSB2.0-learning.html),但里面的 `se::ScriptEngine` 貌似是他们 IDE 里的,只有小部分和 Cocos2d-x 引擎有关(也就是我们需要涉及的部分)。 51 | 52 | 手动绑定在我看了半天代码后,了解到自己需要的程度。我不想把事情弄复杂,注入一个类当作名字空间,把需要的方法作为这个类的静态方法添加进来,JS 能传参,有回调函数就可以满足绝大多数业务上的需求了。 53 | 54 | 其实最终我们要想添加一个新业务是件很简单的事,但看着复杂是因为没有良好的封装。Cocos2d 引擎里集成了 Firefox 浏览器的 JS 引擎——SpiderMonkey,引擎的方法都是暴露出来的,但是注入用到的参数、方法只是很小的一部分,所以在看 Cocos2d 自带的绑定文件时,有大量的重复的内容,而且是我们不需要关心的。 55 | 56 | 我写了一些宏,把不需要关心的部分隐藏掉,下面讲的都是封装后的使用。这种东西,还是例子来得清晰,在 demo 中,iOSBinding 包含所有绑定逻辑,JSBH 里是 js-binding 的辅助工具。 57 | 58 | [iOSBinding.h](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/f78d5dc16bd0c8a5664fc435231b78e9d480d45a/frameworks/runtime-src/proj.ios_mac/iOSBinding.h) 很简单,对外暴露了一个方法,调用即可完成注册。 59 | 60 | ```h 61 | #import 62 | 63 | void jsb_ios_load(); 64 | ``` 65 | 66 | 再看 [iOSBinding.m](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/f78d5dc16bd0c8a5664fc435231b78e9d480d45a/frameworks/runtime-src/proj.ios_mac/iOSBinding.mm#L65),注入类到 JS 的部分不过 30 行 67 | 68 | ```cpp 69 | // 保持简单,只把类当作一个名字空间,不创建实例,构造函数和析构函数即可留空 70 | bool js_class_constructor(JSContext *cx, uint32_t argc, jsval *vp) { 71 | return false; 72 | } 73 | void js_class_finalize(JSFreeOp *fop, JSObject *obj) {} 74 | 75 | // 这部分是描述类的属性、方法和静态方法,用宏包裹起来了三个变量,添加新东西主要就在这 76 | JSBH_GenerateClassRegisteFunction(iOS) 77 | static JSPropertySpec properties[] = { 78 | JS_PS_END 79 | }; 80 | 81 | static JSFunctionSpec funcs[] = { 82 | JS_FS_END 83 | }; 84 | 85 | static JSFunctionSpec st_funcs[] = { 86 | // 添加一个方法,只需关心前两个参数——JS 环境下的方法名、C 方法名 87 | JS_FN("demoAdd", demoAdd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), 88 | JS_FS_END 89 | }; 90 | JSBH_GenerateClassRegisteFunctionEND(iOS) 91 | 92 | // ScriptingCore 注册,没什么好说的 93 | void jsb_ios_load() { 94 | ScriptingCore* sc = ScriptingCore::getInstance(); 95 | sc->addRegisterCallback(jsb_registe); 96 | } 97 | ``` 98 | 99 | JS 可像这样调用: 100 | 101 | ```js 102 | if (iOS) { 103 | var ret = iOS.demoAdd(1, 2); 104 | // 3 105 | } 106 | ``` 107 | 108 | 然后就是方法的实现 [iOSBinding.m](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/f78d5dc16bd0c8a5664fc435231b78e9d480d45a/frameworks/runtime-src/proj.ios_mac/iOSBinding.mm#L14) 109 | 110 | ```cpp 111 | bool demoAdd(JSContext* cx, uint32_t argc, jsval* vp) { 112 | // 检查参数个数 113 | JSBH_FunctionAssertArgcNumber(2); 114 | 115 | // 检查参数类型 116 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 117 | JSBH_FunctionAssertArgsType(0, JSTYPE_NUMBER); 118 | JSBH_FunctionAssertArgsType(1, JSTYPE_NUMBER); 119 | 120 | // 读取参数 121 | bool ok = false; 122 | int a; 123 | int b; 124 | ok = jsval_to_int(cx, args[0], &a); 125 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 126 | ok = jsval_to_int(cx, args[1], &b); 127 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 128 | 129 | // 设置返回值 130 | JSBH_FunctionReturnInt(a + b); 131 | return true; 132 | } 133 | ``` 134 | 135 | 写新的方法照着我的代码改一下就行了,异步回调的见 [iOSBinding.m](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/f78d5dc16bd0c8a5664fc435231b78e9d480d45a/frameworks/runtime-src/proj.ios_mac/iOSBinding.mm#L32) 136 | 137 | 要更复杂的可以看看 cocos2d-x/cocos/scripting/js-bindings/manual 里的实现。 138 | 139 | ## Demo 说明 140 | 141 | 写这个 demo 我的首要目标就是尽可能保持简单、清晰。我不碰 Android 开发的东西,但是这里的方案稍作修改也适用于 Android 和其它平台。 142 | 143 | 工具的话为了简单我不会做全,比如类型转换只有 string 的比较全,需要用的时候自己实现吧。 144 | 145 | 主要涉及的文件: 146 | 147 | * Javascript 部分在 [app.js](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/master/src/app.js) 148 | * 绑定工具在 [JSBH](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/master/frameworks/runtime-src/Classes/JSBH.h) 149 | * 绑定的例子在 [iOSBinding](https://github.com/BB9z/Cocos2d-js-binding-demo/blob/master/frameworks/runtime-src/proj.ios_mac/iOSBinding.mm) 150 | 151 | JSB 的东西我研究并不多,不过两天。踩过的坑,发出来其他人就不用踩了,如有纰漏求指正。 152 | 153 | ## 维护 Cocos2d 项目的建议 154 | 155 | 如果你需要写比较多的原生代码的话: 156 | 157 | * 手动开启 ARC,目前(最新是 3.16 版本) Cocos2d 生成的项目都没开 ARC 的,你不会想写 MRC 代码吧? 158 | * 创建必要的中间层,隔离 C++ 代码。可能是 Cocos2d 引擎符号太多,Objective-C++ 下代码提示非常迟钝,几乎不可用,写 native 代码来说这是不可接受的,至少我这 Xcode 9.2 是这样的。 159 | 160 | 另外,因为很多 OC 的代码是没考虑 C++ 环境的,一但混编动不动就编译不过。加上 Xcode 有编译缓存,可能写出去很多了才发现 build 错误。 161 | 162 | ## 吐槽 163 | 164 | 人生苦短,不吐槽了 😂 165 | -------------------------------------------------------------------------------- /frameworks/cocos2d-html5/README.md: -------------------------------------------------------------------------------- 1 | 为了减少仓库体积,引擎部分的代码没有传,从项目模版或现有项目中拷贝过来即可。 2 | Please copy cocos2d-x engine files from local. 3 | -------------------------------------------------------------------------------- /frameworks/cocos2d-x/README.md: -------------------------------------------------------------------------------- 1 | 为了减少仓库体积,引擎部分的代码没有传,从项目模版或现有项目中拷贝过来即可。 2 | Please copy cocos2d-x engine files from local. 3 | -------------------------------------------------------------------------------- /frameworks/runtime-src/Classes/AppDelegate.cpp: -------------------------------------------------------------------------------- 1 | #include "AppDelegate.h" 2 | 3 | #include "scripting/js-bindings/auto/jsb_cocos2dx_3d_auto.hpp" 4 | #include "scripting/js-bindings/auto/jsb_cocos2dx_3d_extension_auto.hpp" 5 | #include "scripting/js-bindings/auto/jsb_cocos2dx_auto.hpp" 6 | #include "scripting/js-bindings/auto/jsb_cocos2dx_builder_auto.hpp" 7 | #include "scripting/js-bindings/auto/jsb_cocos2dx_extension_auto.hpp" 8 | #include "scripting/js-bindings/auto/jsb_cocos2dx_network_auto.hpp" 9 | #include "scripting/js-bindings/auto/jsb_cocos2dx_navmesh_auto.hpp" 10 | #include "scripting/js-bindings/auto/jsb_cocos2dx_physics3d_auto.hpp" 11 | #include "scripting/js-bindings/auto/jsb_cocos2dx_spine_auto.hpp" 12 | #include "scripting/js-bindings/auto/jsb_cocos2dx_studio_auto.hpp" 13 | #include "scripting/js-bindings/auto/jsb_cocos2dx_ui_auto.hpp" 14 | #include "scripting/js-bindings/manual/3d/jsb_cocos2dx_3d_manual.h" 15 | #include "scripting/js-bindings/manual/chipmunk/js_bindings_chipmunk_registration.h" 16 | #include "scripting/js-bindings/manual/cocosbuilder/js_bindings_ccbreader.h" 17 | #include "scripting/js-bindings/manual/cocostudio/jsb_cocos2dx_studio_manual.h" 18 | #include "scripting/js-bindings/manual/extension/jsb_cocos2dx_extension_manual.h" 19 | #include "scripting/js-bindings/manual/jsb_opengl_registration.h" 20 | #include "scripting/js-bindings/manual/localstorage/js_bindings_system_registration.h" 21 | #include "scripting/js-bindings/manual/navmesh/jsb_cocos2dx_navmesh_manual.h" 22 | #include "scripting/js-bindings/manual/network/XMLHTTPRequest.h" 23 | #include "scripting/js-bindings/manual/network/jsb_socketio.h" 24 | #include "scripting/js-bindings/manual/network/jsb_websocket.h" 25 | #include "scripting/js-bindings/manual/physics3d/jsb_cocos2dx_physics3d_manual.h" 26 | #include "scripting/js-bindings/manual/spine/jsb_cocos2dx_spine_manual.h" 27 | #include "scripting/js-bindings/manual/ui/jsb_cocos2dx_ui_manual.h" 28 | 29 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) 30 | #include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_video_auto.hpp" 31 | #include "scripting/js-bindings/auto/jsb_cocos2dx_experimental_webView_auto.hpp" 32 | #include "scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_video_manual.h" 33 | #include "scripting/js-bindings/manual/experimental/jsb_cocos2dx_experimental_webView_manual.h" 34 | #endif 35 | 36 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) 37 | #include "scripting/js-bindings/auto/jsb_cocos2dx_audioengine_auto.hpp" 38 | #endif 39 | 40 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) 41 | #include "cocos/scripting/js-bindings/manual/platform/android/CCJavascriptJavaBridge.h" 42 | #elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) 43 | #include "cocos/scripting/js-bindings/manual/platform/ios/JavaScriptObjCBridge.h" 44 | #endif 45 | 46 | // #define USE_AUDIO_ENGINE 1 47 | // #define USE_SIMPLE_AUDIO_ENGINE 1 48 | 49 | #if USE_AUDIO_ENGINE && USE_SIMPLE_AUDIO_ENGINE 50 | #error "Don't use AudioEngine and SimpleAudioEngine at the same time. Please just select one in your game!" 51 | #endif 52 | 53 | #if USE_AUDIO_ENGINE 54 | #include "audio/include/AudioEngine.h" 55 | using namespace cocos2d::experimental; 56 | #elif USE_SIMPLE_AUDIO_ENGINE 57 | #include "audio/include/SimpleAudioEngine.h" 58 | using namespace CocosDenshion; 59 | #endif 60 | 61 | USING_NS_CC; 62 | 63 | AppDelegate::AppDelegate() 64 | { 65 | } 66 | 67 | AppDelegate::~AppDelegate() 68 | { 69 | #if USE_AUDIO_ENGINE 70 | AudioEngine::end(); 71 | #elif USE_SIMPLE_AUDIO_ENGINE 72 | SimpleAudioEngine::end(); 73 | #endif 74 | ScriptEngineManager::destroyInstance(); 75 | } 76 | 77 | void AppDelegate::initGLContextAttrs() 78 | { 79 | GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8}; 80 | 81 | GLView::setGLContextAttrs(glContextAttrs); 82 | } 83 | 84 | bool AppDelegate::applicationDidFinishLaunching() 85 | { 86 | // initialize director 87 | auto director = Director::getInstance(); 88 | auto glview = director->getOpenGLView(); 89 | if(!glview) { 90 | #if(CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT) 91 | glview = cocos2d::GLViewImpl::create("iOS_JSB"); 92 | #else 93 | glview = cocos2d::GLViewImpl::createWithRect("iOS_JSB", Rect(0,0,960,640)); 94 | #endif 95 | director->setOpenGLView(glview); 96 | } 97 | 98 | // set FPS. the default value is 1.0/60 if you don't call this 99 | director->setAnimationInterval(1.0f / 60); 100 | 101 | ScriptingCore* sc = ScriptingCore::getInstance(); 102 | sc->addRegisterCallback(register_all_cocos2dx); 103 | sc->addRegisterCallback(register_cocos2dx_js_core); 104 | sc->addRegisterCallback(jsb_register_system); 105 | 106 | // extension can be commented out to reduce the package 107 | sc->addRegisterCallback(register_all_cocos2dx_extension); 108 | sc->addRegisterCallback(register_all_cocos2dx_extension_manual); 109 | 110 | // chipmunk can be commented out to reduce the package 111 | sc->addRegisterCallback(jsb_register_chipmunk); 112 | // opengl can be commented out to reduce the package 113 | sc->addRegisterCallback(JSB_register_opengl); 114 | 115 | // builder can be commented out to reduce the package 116 | sc->addRegisterCallback(register_all_cocos2dx_builder); 117 | sc->addRegisterCallback(register_CCBuilderReader); 118 | 119 | // ui can be commented out to reduce the package, attention studio need ui module 120 | sc->addRegisterCallback(register_all_cocos2dx_ui); 121 | sc->addRegisterCallback(register_all_cocos2dx_ui_manual); 122 | 123 | // studio can be commented out to reduce the package, 124 | sc->addRegisterCallback(register_all_cocos2dx_studio); 125 | sc->addRegisterCallback(register_all_cocos2dx_studio_manual); 126 | 127 | // spine can be commented out to reduce the package 128 | sc->addRegisterCallback(register_all_cocos2dx_spine); 129 | sc->addRegisterCallback(register_all_cocos2dx_spine_manual); 130 | 131 | // XmlHttpRequest can be commented out to reduce the package 132 | sc->addRegisterCallback(MinXmlHttpRequest::_js_register); 133 | // websocket can be commented out to reduce the package 134 | sc->addRegisterCallback(register_jsb_websocket); 135 | // socket io can be commented out to reduce the package 136 | sc->addRegisterCallback(register_jsb_socketio); 137 | // Downloader 138 | sc->addRegisterCallback(register_all_cocos2dx_network); 139 | 140 | // 3d can be commented out to reduce the package 141 | sc->addRegisterCallback(register_all_cocos2dx_3d); 142 | sc->addRegisterCallback(register_all_cocos2dx_3d_manual); 143 | 144 | // 3d extension can be commented out to reduce the package 145 | sc->addRegisterCallback(register_all_cocos2dx_3d_extension); 146 | 147 | #if CC_USE_3D_PHYSICS && CC_ENABLE_BULLET_INTEGRATION 148 | // Physics 3d can be commented out to reduce the package 149 | sc->addRegisterCallback(register_all_cocos2dx_physics3d); 150 | sc->addRegisterCallback(register_all_cocos2dx_physics3d_manual); 151 | #endif 152 | 153 | #if CC_USE_NAVMESH 154 | sc->addRegisterCallback(register_all_cocos2dx_navmesh); 155 | sc->addRegisterCallback(register_all_cocos2dx_navmesh_manual); 156 | #endif 157 | 158 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) 159 | sc->addRegisterCallback(register_all_cocos2dx_experimental_video); 160 | sc->addRegisterCallback(register_all_cocos2dx_experimental_video_manual); 161 | sc->addRegisterCallback(register_all_cocos2dx_experimental_webView); 162 | sc->addRegisterCallback(register_all_cocos2dx_experimental_webView_manual); 163 | #endif 164 | 165 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_WINRT || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) 166 | sc->addRegisterCallback(register_all_cocos2dx_audioengine); 167 | #endif 168 | 169 | #if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) 170 | sc->addRegisterCallback(JavascriptJavaBridge::_js_register); 171 | #elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) 172 | sc->addRegisterCallback(JavaScriptObjCBridge::_js_register); 173 | #endif 174 | sc->start(); 175 | sc->runScript("script/jsb_boot.js"); 176 | #if defined(COCOS2D_DEBUG) && (COCOS2D_DEBUG > 0) 177 | sc->enableDebugger(); 178 | #endif 179 | ScriptEngineProtocol *engine = ScriptingCore::getInstance(); 180 | ScriptEngineManager::getInstance()->setScriptEngine(engine); 181 | ScriptingCore::getInstance()->runScript("main.js"); 182 | 183 | return true; 184 | } 185 | 186 | // This function will be called when the app is inactive. Note, when receiving a phone call it is invoked. 187 | void AppDelegate::applicationDidEnterBackground() 188 | { 189 | auto director = Director::getInstance(); 190 | director->stopAnimation(); 191 | director->getEventDispatcher()->dispatchCustomEvent("game_on_hide"); 192 | 193 | #if USE_AUDIO_ENGINE 194 | AudioEngine::pauseAll(); 195 | #elif USE_SIMPLE_AUDIO_ENGINE 196 | SimpleAudioEngine::getInstance()->pauseBackgroundMusic(); 197 | SimpleAudioEngine::getInstance()->pauseAllEffects(); 198 | #endif 199 | } 200 | 201 | // this function will be called when the app is active again 202 | void AppDelegate::applicationWillEnterForeground() 203 | { 204 | auto director = Director::getInstance(); 205 | director->startAnimation(); 206 | director->getEventDispatcher()->dispatchCustomEvent("game_on_show"); 207 | 208 | #if USE_AUDIO_ENGINE 209 | AudioEngine::resumeAll(); 210 | #elif USE_SIMPLE_AUDIO_ENGINE 211 | SimpleAudioEngine::getInstance()->resumeBackgroundMusic(); 212 | SimpleAudioEngine::getInstance()->resumeAllEffects(); 213 | #endif 214 | } 215 | -------------------------------------------------------------------------------- /frameworks/runtime-src/Classes/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // GCTestAppDelegate.h 3 | // GCTest 4 | // 5 | // Created by Rohan Kuruvilla on 06/08/2012. 6 | // Copyright __MyCompanyName__ 2012. All rights reserved. 7 | // 8 | 9 | #ifndef _APP_DELEGATE_H_ 10 | #define _APP_DELEGATE_H_ 11 | 12 | #include "platform/CCApplication.h" 13 | /** 14 | @brief The cocos2d Application. 15 | 16 | Private inheritance here hides part of interface from Director. 17 | */ 18 | class AppDelegate : private cocos2d::Application 19 | { 20 | public: 21 | AppDelegate(); 22 | virtual ~AppDelegate(); 23 | 24 | void initGLContextAttrs() override; 25 | 26 | /** 27 | @brief Implement Director and Scene init code here. 28 | @return true Initialize success, app continue. 29 | @return false Initialize failed, app terminate. 30 | */ 31 | virtual bool applicationDidFinishLaunching(); 32 | 33 | /** 34 | @brief Called when the application moves to the background 35 | @param the pointer of the application 36 | */ 37 | virtual void applicationDidEnterBackground(); 38 | 39 | /** 40 | @brief Called when the application reenters the foreground 41 | @param the pointer of the application 42 | */ 43 | virtual void applicationWillEnterForeground(); 44 | }; 45 | 46 | #endif // _APP_DELEGATE_H_ 47 | 48 | -------------------------------------------------------------------------------- /frameworks/runtime-src/Classes/JSBH.h: -------------------------------------------------------------------------------- 1 | /*! 2 | Cocos2d-x js-binding 辅助工具 3 | 4 | */ 5 | #pragma once 6 | 7 | #import "scripting/js-bindings/manual/jsb_helper.h" 8 | #import "scripting/js-bindings/manual/ScriptingCore.h" 9 | #import "scripting/js-bindings/manual/cocos2d_specifics.hpp" 10 | 11 | /** 12 | 生成类注册方法,一个文件只能用一次 13 | 14 | 使用,需要 js_class_constructor,js_class_finalize 方法已定义 15 | @code 16 | JSBH_GenerateClassRegisteFunction(iOS) 17 | static JSPropertySpec properties[] = { 18 | JS_PS_END 19 | }; 20 | static JSFunctionSpec funcs[] = { 21 | JS_FS_END 22 | }; 23 | static JSFunctionSpec st_funcs[] = { 24 | JS_FS_END 25 | }; 26 | JSBH_GenerateClassRegisteFunctionEND(iOS) 27 | @endcode 28 | 29 | 生成的方法通过 addRegisterCallback 注入 JS 环境 30 | @code 31 | ScriptingCore *sc = ScriptingCore::getInstance(); 32 | sc->addRegisterCallback(jsb_registe); 33 | @endcode 34 | */ 35 | #define JSBH_GenerateClassRegisteFunction(CLASS_NAME) \ 36 | JSClass *js_class;\ 37 | JSObject *js_class_prototype;\ 38 | void jsb_registe(JSContext *cx, JS::HandleObject global) {\ 39 | js_class = (JSClass *)calloc(1, sizeof(JSClass));\ 40 | js_class->name = #CLASS_NAME;\ 41 | js_class->addProperty = JS_PropertyStub;\ 42 | js_class->delProperty = JS_DeletePropertyStub;\ 43 | js_class->getProperty = JS_PropertyStub;\ 44 | js_class->setProperty = JS_StrictPropertyStub;\ 45 | js_class->enumerate = JS_EnumerateStub;\ 46 | js_class->resolve = JS_ResolveStub;\ 47 | js_class->convert = JS_ConvertStub;\ 48 | js_class->finalize = js_class_finalize;\ 49 | js_class->flags = JSCLASS_HAS_RESERVED_SLOTS(2); 50 | 51 | #define JSBH_GenerateClassRegisteFunctionEND(CLASS_NAME) \ 52 | js_class_prototype = JS_InitClass(cx, global, JS::NullPtr(), js_class,\ 53 | js_class_constructor, 0,\ 54 | nullptr, funcs, properties, st_funcs);\ 55 | anonEvaluate(cx, global, "(function () { return " #CLASS_NAME "; })()").toObjectOrNull();\ 56 | } 57 | 58 | #define JSBH_GenerateFuncCallback(ARGS_INDEX, CALLBACK_NAME, ...)\ 59 | JS::RootedObject jstarget(cx, args.thisv().toObjectOrNull());\ 60 | std::shared_ptr func(new JSFunctionWrapper(cx, jstarget, args.get(ARGS_INDEX), args.thisv()));\ 61 | auto CALLBACK_NAME = [=](__VA_ARGS__) -> void 62 | 63 | /** 64 | 设置返回给 JS 的方法返回值,字符串类型 65 | 66 | 参数必须是 C string 67 | */ 68 | #define JSBH_FunctionReturnString(C_STR)\ 69 | args.rval().set(STRING_TO_JSVAL(JS_NewStringCopyZ(cx, C_STR))); 70 | 71 | /** 72 | 设置返回给 JS 的方法返回值,整型 73 | */ 74 | #define JSBH_FunctionReturnInt(INT)\ 75 | args.rval().set(INT_TO_JSVAL(INT)); 76 | 77 | /** 78 | 设置返回给 JS 的方法返回值,null 79 | */ 80 | #define JSBH_FunctionReturnNull()\ 81 | args.rval().set(JSVAL_NULL); 82 | 83 | /** 84 | 断言参数个数 85 | */ 86 | #define JSBH_FunctionAssertArgcNumber(NUM)\ 87 | if (argc != NUM) {\ 88 | JS_ReportError(cx, "%s: 参数个数错误", __FUNCTION__);\ 89 | return false;\ 90 | } 91 | 92 | /** 93 | 断言参数类型 94 | */ 95 | #define JSBH_FunctionAssertArgsType(NUM, JSTYPE)\ 96 | if (JS_TypeOfValue(cx, args.get(NUM)) != JSTYPE) {\ 97 | JS_ReportError(cx, "%s: 参数不是 %s", __FUNCTION__, #JSTYPE);\ 98 | return false;\ 99 | } 100 | 101 | /// 转换 std::string => NSString 102 | extern NSString *NSStringFromSTDString(std::string str); 103 | 104 | /// 转换 NSString => std::string 105 | extern std::string STDStringFromNSString(NSString *str); 106 | 107 | /** 108 | 生成约定的错误格式 109 | 110 | 如果 code 和 message 都为空,返回 JSVAL_NULL 111 | */ 112 | extern jsval JSBH_Error(JSContext *cx, NSString *code, NSString *message); 113 | 114 | /// 转换 NSString => jsval 115 | extern jsval JSBH_String(JSContext *cx, NSString *string); 116 | 117 | /** 118 | 调用无返回值的 JS 代码 119 | 120 | @param evalString JS 脚本字符串 121 | @return 脚本执行失败返回 NO 122 | */ 123 | BOOL JSBH_EvalJSStringWithoutReturn(NSString *evalString); 124 | 125 | /** 126 | 调用返回值是 string 类型的 JS 代码 127 | 128 | @param evalString JS 脚本字符串 129 | @return 脚本执行失败返回 nil 130 | */ 131 | NSString *JSBH_EvalJSStringReturnString(NSString *evalString); 132 | 133 | -------------------------------------------------------------------------------- /frameworks/runtime-src/Classes/JSBH.mm: -------------------------------------------------------------------------------- 1 | 2 | #import "JSBH.h" 3 | 4 | NSString *NSStringFromSTDString(std::string str) { 5 | return @(str.c_str()); 6 | } 7 | 8 | std::string STDStringFromNSString(NSString *str) { 9 | return std::string(str.UTF8String); 10 | } 11 | 12 | #define jsobj_addStringProperty(OBJ, NAME, VALUE) \ 13 | JS_DefineProperty(cx, OBJ, NAME, JS::RootedValue(cx, std_string_to_jsval(cx, STDStringFromNSString(VALUE))), JSPROP_ENUMERATE | JSPROP_PERMANENT) 14 | 15 | jsval JSBH_Error(JSContext *cx, NSString *code, NSString *message) { 16 | if (!code && !message) return JSVAL_NULL; 17 | JS::RootedObject tmp(cx, JS_NewObject(cx, NULL, JS::NullPtr(), JS::NullPtr())); 18 | if (!tmp) return JSVAL_NULL; 19 | bool ok = jsobj_addStringProperty(tmp, "code", code?: @"") 20 | && jsobj_addStringProperty(tmp, "message", message?: @""); 21 | if (ok) { 22 | return OBJECT_TO_JSVAL(tmp); 23 | } 24 | return JSVAL_NULL; 25 | } 26 | 27 | jsval JSBH_String(JSContext *cx, NSString *string) { 28 | return string? std_string_to_jsval(cx, STDStringFromNSString(string)) : JSVAL_NULL; 29 | } 30 | 31 | BOOL JSBH_EvalJSStringWithoutReturn(NSString *evalString) { 32 | if (!evalString.length) return nil; 33 | return ScriptingCore::getInstance()->evalString(evalString.UTF8String); 34 | } 35 | 36 | /** 37 | 还是为了简便,只写了一个返回值是 string 的方法作为演示 38 | 如需其它类型,查看一下还有哪些 jsval_to_ 方法稍作修改即可 39 | 40 | 如果 Cocos2d-x 的版本很老的话,返回值要这样写 41 | jsval retVal; 42 | ScriptingCore::getInstance()->evalString(string, &retVal) 43 | http://forum.cocos.com/t/scriptingcore-getinstance-evalstring/40686 44 | */ 45 | NSString *JSBH_EvalJSStringReturnString(NSString *evalString) { 46 | if (!evalString.length) return nil; 47 | auto cx = ScriptingCore::getInstance()->getGlobalContext(); 48 | JS::RootedValue retVal(cx); 49 | if (!ScriptingCore::getInstance()->evalString(evalString.UTF8String, &retVal)) return nil; 50 | std::string string; 51 | jsval_to_std_string(cx, retVal, &string); 52 | return NSStringFromSTDString(string); 53 | } 54 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | /local.properties 3 | /.idea/workspace.xml 4 | /.idea/libraries 5 | .DS_Store 6 | /build 7 | /captures 8 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /jniLibs 3 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | 7 | 8 | 12 | 13 | 14 | 16 | 17 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/build.gradle: -------------------------------------------------------------------------------- 1 | import org.apache.tools.ant.taskdefs.condition.Os 2 | 3 | apply plugin: 'com.android.application' 4 | 5 | android { 6 | compileSdkVersion PROP_COMPILE_SDK_VERSION.toInteger() 7 | buildToolsVersion "25.0.0" 8 | 9 | defaultConfig { 10 | applicationId "com.test.ios_jsb" 11 | minSdkVersion PROP_MIN_SDK_VERSION 12 | targetSdkVersion PROP_TARGET_SDK_VERSION 13 | versionCode 1 14 | versionName "1.0" 15 | 16 | externalNativeBuild { 17 | ndkBuild { 18 | if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) { 19 | // skip the NDK Build step if PROP_NDK_MODE is none 20 | targets 'cocos2djs' 21 | arguments 'NDK_TOOLCHAIN_VERSION=4.9' 22 | arguments 'APP_PLATFORM=android-'+PROP_APP_PLATFORM 23 | 24 | def module_paths = [project.file("../../../cocos2d-x").absolutePath, 25 | project.file("../../../cocos2d-x/cocos").absolutePath, 26 | project.file("../../../cocos2d-x/external").absolutePath] 27 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 28 | // should use '/' 29 | module_paths = module_paths.collect {it.replaceAll('\\\\', '/')} 30 | arguments 'NDK_MODULE_PATH=' + module_paths.join(";") 31 | } 32 | else { 33 | arguments 'NDK_MODULE_PATH=' + module_paths.join(':') 34 | } 35 | 36 | arguments '-j' + Runtime.runtime.availableProcessors() 37 | abiFilters.addAll(PROP_APP_ABI.split(':').collect{it as String}) 38 | } 39 | } 40 | } 41 | } 42 | 43 | sourceSets.main { 44 | java.srcDir "src" 45 | res.srcDir "res" 46 | jniLibs.srcDir "libs" 47 | manifest.srcFile "AndroidManifest.xml" 48 | } 49 | 50 | externalNativeBuild { 51 | ndkBuild { 52 | if (!project.hasProperty("PROP_NDK_MODE") || PROP_NDK_MODE.compareTo('none') != 0) { 53 | // skip the NDK Build step if PROP_NDK_MODE is none 54 | path "jni/Android.mk" 55 | } 56 | } 57 | } 58 | 59 | signingConfigs { 60 | 61 | release { 62 | if (project.hasProperty("RELEASE_STORE_FILE")) { 63 | storeFile file(RELEASE_STORE_FILE) 64 | storePassword RELEASE_STORE_PASSWORD 65 | keyAlias RELEASE_KEY_ALIAS 66 | keyPassword RELEASE_KEY_PASSWORD 67 | } 68 | } 69 | } 70 | 71 | buildTypes { 72 | release { 73 | minifyEnabled false 74 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 75 | if (project.hasProperty("RELEASE_STORE_FILE")) { 76 | signingConfig signingConfigs.release 77 | } 78 | 79 | externalNativeBuild { 80 | ndkBuild { 81 | arguments 'NDK_DEBUG=0' 82 | } 83 | } 84 | } 85 | 86 | debug { 87 | externalNativeBuild { 88 | ndkBuild { 89 | arguments 'NDK_DEBUG=1' 90 | } 91 | } 92 | } 93 | } 94 | } 95 | 96 | def getCocosCommandPath() { 97 | if (Os.isFamily(Os.FAMILY_WINDOWS)) { 98 | return 'cocos.bat' 99 | } 100 | else { 101 | // on unix like system, can not get environments variables easily 102 | // so run a shell script to get environment variable sets by cocos2d-x setup.py 103 | new ByteArrayOutputStream().withStream { os -> 104 | def result = exec { 105 | executable = project.file('get_environment.sh') 106 | standardOutput = os 107 | } 108 | ext.console_path = os.toString().trim() 109 | } 110 | return new File(console_path + '/cocos').absolutePath; 111 | } 112 | } 113 | 114 | 115 | // a method used to invoke the cocos jscompile command 116 | def compileJS(srcDir, dstDir) { 117 | def compileArgs = ['jscompile', '-s', srcDir, '-d', dstDir] 118 | 119 | println 'running command : ' + 'cocos ' + compileArgs.join(' ') 120 | exec { 121 | // if you meet problem, just replace `getCocosCommandPath()` to the path of cocos command 122 | executable getCocosCommandPath() 123 | args compileArgs 124 | } 125 | 126 | // remove the js files in dstDir 127 | delete fileTree(dstDir) { 128 | include '**/*.js' 129 | } 130 | } 131 | 132 | android.applicationVariants.all { variant -> 133 | // delete previous files first 134 | delete "${buildDir}/intermediates/assets/${variant.dirName}" 135 | 136 | variant.mergeAssets.doLast { 137 | copy { 138 | from "${buildDir}/../../../../../res" 139 | into "${buildDir}/intermediates/assets/${variant.dirName}/res" 140 | } 141 | 142 | copy { 143 | from "${buildDir}/../../../../../src" 144 | into "${buildDir}/intermediates/assets/${variant.dirName}/src" 145 | } 146 | 147 | copy { 148 | from "${buildDir}/../../../../cocos2d-x/cocos/scripting/js-bindings/script" 149 | into "${buildDir}/intermediates/assets/${variant.dirName}/script" 150 | } 151 | 152 | copy { 153 | from "${buildDir}/../../../../../main.js" 154 | from "${buildDir}/../../../../../project.json" 155 | into "${buildDir}/intermediates/assets/${variant.dirName}" 156 | } 157 | 158 | // compile the scripts if necessary 159 | def compileScript = (variant.name.compareTo('release') == 0) 160 | if (project.hasProperty('PROP_COMPILE_SCRIPT')) { 161 | compileScript = (PROP_COMPILE_SCRIPT.compareTo('1') == 0) 162 | } 163 | 164 | if (compileScript) { 165 | compileJS("${buildDir}/intermediates/assets/${variant.dirName}", 166 | "${buildDir}/intermediates/assets/${variant.dirName}") 167 | } 168 | } 169 | } 170 | 171 | dependencies { 172 | compile fileTree(dir: 'libs', include: ['*.jar']) 173 | compile project(':libcocos2dx') 174 | } 175 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/get_environment.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | source ~/.bash_profile 4 | echo $COCOS_CONSOLE_ROOT -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := cocos2djs_shared 6 | 7 | LOCAL_MODULE_FILENAME := libcocos2djs 8 | 9 | LOCAL_SRC_FILES := hellojavascript/main.cpp \ 10 | ../../../Classes/AppDelegate.cpp 11 | 12 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../../Classes 13 | 14 | LOCAL_STATIC_LIBRARIES := cocos2d_js_static 15 | 16 | LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT 17 | 18 | include $(BUILD_SHARED_LIBRARY) 19 | 20 | 21 | $(call import-module, scripting/js-bindings/proj.android) 22 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := gnustl_static 2 | 3 | # Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices 4 | #APP_ABI := armeabi-v7a 5 | 6 | APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char 7 | APP_LDFLAGS := -latomic 8 | 9 | APP_ABI := armeabi 10 | APP_SHORT_COMMANDS := true 11 | 12 | USE_ARM_MODE := 1 13 | 14 | ifeq ($(NDK_DEBUG),1) 15 | APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 16 | APP_OPTIM := debug 17 | else 18 | APP_CPPFLAGS += -DNDEBUG 19 | APP_OPTIM := release 20 | endif 21 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/jni/hellojavascript/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include "AppDelegate.h" 7 | 8 | #define LOG_TAG "main" 9 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 10 | 11 | namespace { 12 | std::unique_ptr appDelegate; 13 | } 14 | 15 | void cocos_android_app_init(JNIEnv* env) { 16 | LOGD("cocos_android_app_init"); 17 | appDelegate.reset(new AppDelegate()); 18 | } 19 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/proguard-rules.pro: -------------------------------------------------------------------------------- 1 | # Add project specific ProGuard rules here. 2 | # By default, the flags in this file are appended to flags specified 3 | # in E:\developSoftware\Android\SDK/tools/proguard/proguard-android.txt 4 | # You can edit the include path and order by changing the proguardFiles 5 | # directive in build.gradle. 6 | # 7 | # For more details, see 8 | # http://developer.android.com/guide/developing/tools/proguard.html 9 | 10 | # Add any project specific keep options here: 11 | 12 | # If your project uses WebView with JS, uncomment the following 13 | # and specify the fully qualified class name to the JavaScript interface 14 | # class: 15 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 16 | # public *; 17 | #} 18 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android-studio/app/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android-studio/app/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android-studio/app/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | iOS_JSB 3 | 4 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/app/src/org/cocos2dx/javascript/AppActivity.java: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2015-2017 Chukong Technologies Inc. 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | package org.cocos2dx.javascript; 25 | 26 | import android.os.Bundle; 27 | import org.cocos2dx.lib.Cocos2dxActivity; 28 | import org.cocos2dx.lib.Cocos2dxGLSurfaceView; 29 | 30 | public class AppActivity extends Cocos2dxActivity { 31 | @Override 32 | protected void onCreate(Bundle savedInstanceState) { 33 | super.setEnableVirtualButton(false); 34 | super.onCreate(savedInstanceState); 35 | // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 36 | if (!isTaskRoot()) { 37 | // Android launched another instance of the root activity into an existing task 38 | // so just quietly finish and go away, dropping the user back into the activity 39 | // at the top of the stack (ie: the last state of this task) 40 | // Don't need to finish it again since it's finished in super.onCreate . 41 | return; 42 | } 43 | 44 | // DO OTHER INITIALIZATION BELOW 45 | 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/build.gradle: -------------------------------------------------------------------------------- 1 | // Top-level build file where you can add configuration options common to all sub-projects/modules. 2 | 3 | buildscript { 4 | repositories { 5 | jcenter() 6 | } 7 | dependencies { 8 | classpath 'com.android.tools.build:gradle:2.3.3' 9 | 10 | // NOTE: Do not place your application dependencies here; they belong 11 | // in the individual module build.gradle files 12 | } 13 | } 14 | 15 | allprojects { 16 | repositories { 17 | jcenter() 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | 3 | # IDE (e.g. Android Studio) users: 4 | # Gradle settings configured through the IDE *will override* 5 | # any settings specified in this file. 6 | 7 | # For more details on how to configure your build environment visit 8 | # http://www.gradle.org/docs/current/userguide/build_environment.html 9 | 10 | # Specifies the JVM arguments used for the daemon process. 11 | # The setting is particularly useful for tweaking memory settings. 12 | # Default value: -Xmx10248m -XX:MaxPermSize=256m 13 | # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 14 | 15 | # When configured, Gradle will run in incubating parallel mode. 16 | # This option should only be used with decoupled projects. More details, visit 17 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 18 | # org.gradle.parallel=true 19 | PROP_COMPILE_SDK_VERSION=14 20 | PROP_MIN_SDK_VERSION=10 21 | PROP_TARGET_SDK_VERSION=22 22 | PROP_APP_PLATFORM=10 23 | PROP_APP_ABI=armeabi 24 | 25 | # uncomment it and fill in sign information for release mode 26 | #RELEASE_STORE_FILE=file path of keystore 27 | #RELEASE_STORE_PASSWORD=password of keystore 28 | #RELEASE_KEY_ALIAS=alias of key 29 | #RELEASE_KEY_PASSWORD=password of key 30 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Tue Mar 14 17:40:59 CST 2017 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip 7 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 10 | DEFAULT_JVM_OPTS="" 11 | 12 | APP_NAME="Gradle" 13 | APP_BASE_NAME=`basename "$0"` 14 | 15 | # Use the maximum available, or set MAX_FD != -1 to use that value. 16 | MAX_FD="maximum" 17 | 18 | warn ( ) { 19 | echo "$*" 20 | } 21 | 22 | die ( ) { 23 | echo 24 | echo "$*" 25 | echo 26 | exit 1 27 | } 28 | 29 | # OS specific support (must be 'true' or 'false'). 30 | cygwin=false 31 | msys=false 32 | darwin=false 33 | case "`uname`" in 34 | CYGWIN* ) 35 | cygwin=true 36 | ;; 37 | Darwin* ) 38 | darwin=true 39 | ;; 40 | MINGW* ) 41 | msys=true 42 | ;; 43 | esac 44 | 45 | # For Cygwin, ensure paths are in UNIX format before anything is touched. 46 | if $cygwin ; then 47 | [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` 48 | fi 49 | 50 | # Attempt to set APP_HOME 51 | # Resolve links: $0 may be a link 52 | PRG="$0" 53 | # Need this for relative symlinks. 54 | while [ -h "$PRG" ] ; do 55 | ls=`ls -ld "$PRG"` 56 | link=`expr "$ls" : '.*-> \(.*\)$'` 57 | if expr "$link" : '/.*' > /dev/null; then 58 | PRG="$link" 59 | else 60 | PRG=`dirname "$PRG"`"/$link" 61 | fi 62 | done 63 | SAVED="`pwd`" 64 | cd "`dirname \"$PRG\"`/" >&- 65 | APP_HOME="`pwd -P`" 66 | cd "$SAVED" >&- 67 | 68 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 69 | 70 | # Determine the Java command to use to start the JVM. 71 | if [ -n "$JAVA_HOME" ] ; then 72 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 73 | # IBM's JDK on AIX uses strange locations for the executables 74 | JAVACMD="$JAVA_HOME/jre/sh/java" 75 | else 76 | JAVACMD="$JAVA_HOME/bin/java" 77 | fi 78 | if [ ! -x "$JAVACMD" ] ; then 79 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 80 | 81 | Please set the JAVA_HOME variable in your environment to match the 82 | location of your Java installation." 83 | fi 84 | else 85 | JAVACMD="java" 86 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 87 | 88 | Please set the JAVA_HOME variable in your environment to match the 89 | location of your Java installation." 90 | fi 91 | 92 | # Increase the maximum file descriptors if we can. 93 | if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then 94 | MAX_FD_LIMIT=`ulimit -H -n` 95 | if [ $? -eq 0 ] ; then 96 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 97 | MAX_FD="$MAX_FD_LIMIT" 98 | fi 99 | ulimit -n $MAX_FD 100 | if [ $? -ne 0 ] ; then 101 | warn "Could not set maximum file descriptor limit: $MAX_FD" 102 | fi 103 | else 104 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 105 | fi 106 | fi 107 | 108 | # For Darwin, add options to specify how the application appears in the dock 109 | if $darwin; then 110 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 111 | fi 112 | 113 | # For Cygwin, switch paths to Windows format before running java 114 | if $cygwin ; then 115 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 116 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules 158 | function splitJvmOpts() { 159 | JVM_OPTS=("$@") 160 | } 161 | eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS 162 | JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" 163 | 164 | exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" 165 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 12 | set DEFAULT_JVM_OPTS= 13 | 14 | set DIRNAME=%~dp0 15 | if "%DIRNAME%" == "" set DIRNAME=. 16 | set APP_BASE_NAME=%~n0 17 | set APP_HOME=%DIRNAME% 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windowz variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | if "%@eval[2+2]" == "4" goto 4NT_args 53 | 54 | :win9xME_args 55 | @rem Slurp the command line arguments. 56 | set CMD_LINE_ARGS= 57 | set _SKIP=2 58 | 59 | :win9xME_args_slurp 60 | if "x%~1" == "x" goto execute 61 | 62 | set CMD_LINE_ARGS=%* 63 | goto execute 64 | 65 | :4NT_args 66 | @rem Get arguments from the 4NT Shell from JP Software 67 | set CMD_LINE_ARGS=%$ 68 | 69 | :execute 70 | @rem Setup the command line 71 | 72 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 73 | 74 | @rem Execute Gradle 75 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 76 | 77 | :end 78 | @rem End local scope for the variables with windows NT shell 79 | if "%ERRORLEVEL%"=="0" goto mainEnd 80 | 81 | :fail 82 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 83 | rem the _cmd.exe /c_ return code! 84 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 85 | exit /b 1 86 | 87 | :mainEnd 88 | if "%OS%"=="Windows_NT" endlocal 89 | 90 | :omega 91 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android-studio/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':libcocos2dx' 2 | project(':libcocos2dx').projectDir = new File(settingsDir, '../../cocos2d-x/cocos/platform/android/libcocos2dx') 3 | include ':iOS_JSB' 4 | project(':iOS_JSB').projectDir = new File(settingsDir, 'app') 5 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | iOS_JSB 4 | 5 | 6 | 7 | 8 | 9 | com.android.ide.eclipse.adt.ResourceManagerBuilder 10 | 11 | 12 | 13 | 14 | com.android.ide.eclipse.adt.PreCompilerBuilder 15 | 16 | 17 | 18 | 19 | org.eclipse.jdt.core.javabuilder 20 | 21 | 22 | 23 | 24 | com.android.ide.eclipse.adt.ApkBuilder 25 | 26 | 27 | 28 | 29 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 30 | full,incremental, 31 | 32 | 33 | 34 | 35 | 36 | com.android.ide.eclipse.adt.AndroidNature 37 | org.eclipse.jdt.core.javanature 38 | org.eclipse.cdt.core.cnature 39 | org.eclipse.cdt.core.ccnature 40 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 41 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 42 | 43 | 44 | 45 | jsjavabridge 46 | 2 47 | PARENT-2-PROJECT_LOC/cocos2d-x/cocos/platform/android/java/src 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 3 | org.eclipse.jdt.core.compiler.compliance=1.6 4 | org.eclipse.jdt.core.compiler.source=1.6 5 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 7 | 8 | 9 | 10 | 11 | 13 | 14 | 15 | 16 | 17 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/README.md: -------------------------------------------------------------------------------- 1 | Reference:[compilation in eclipse](https://github.com/chukong/cocos-docs/blob/master/manual/framework/html5/v3/compilation-in-eclipse/en.md) -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/ant.properties: -------------------------------------------------------------------------------- 1 | aapt.ignore.assets="!*.pvr.gz:!*.gz:!.svn:!.git:.*:_*:!CVS:!thumbs.db:!picasa.ini:!*.scc:*~" 2 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/build-cfg.json: -------------------------------------------------------------------------------- 1 | { 2 | "ndk_module_path" :[ 3 | "../../cocos2d-x", 4 | "../../cocos2d-x/cocos", 5 | "../../cocos2d-x/external" 6 | ], 7 | "copy_resources": [ 8 | { 9 | "from": "../../../src", 10 | "to": "src" 11 | }, 12 | { 13 | "from": "../../../res", 14 | "to": "res" 15 | }, 16 | { 17 | "from": "../../../main.js", 18 | "to": "" 19 | }, 20 | { 21 | "from": "../../../project.json", 22 | "to": "" 23 | }, 24 | { 25 | "from": "../../cocos2d-x/cocos/scripting/js-bindings/script", 26 | "to": "script" 27 | } 28 | ] 29 | } 30 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/build.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 7 | 8 | 9 | 29 | 30 | 31 | 35 | 36 | 37 | 38 | 39 | 40 | 49 | 50 | 51 | 52 | 56 | 57 | 69 | 70 | 71 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/jni/Android.mk: -------------------------------------------------------------------------------- 1 | LOCAL_PATH := $(call my-dir) 2 | 3 | include $(CLEAR_VARS) 4 | 5 | LOCAL_MODULE := cocos2djs_shared 6 | 7 | LOCAL_MODULE_FILENAME := libcocos2djs 8 | 9 | ifeq ($(USE_ARM_MODE),1) 10 | LOCAL_ARM_MODE := arm 11 | endif 12 | 13 | LOCAL_SRC_FILES := hellojavascript/main.cpp \ 14 | ../../Classes/AppDelegate.cpp 15 | 16 | LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes 17 | 18 | LOCAL_STATIC_LIBRARIES := cocos2d_js_static 19 | 20 | LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT 21 | 22 | include $(BUILD_SHARED_LIBRARY) 23 | 24 | 25 | $(call import-module, scripting/js-bindings/proj.android) 26 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/jni/Application.mk: -------------------------------------------------------------------------------- 1 | APP_STL := gnustl_static 2 | 3 | # Uncomment this line to compile to armeabi-v7a, your application will run faster but support less devices 4 | #APP_ABI := armeabi-v7a 5 | 6 | APP_CPPFLAGS := -frtti -DCC_ENABLE_CHIPMUNK_INTEGRATION=1 -std=c++11 -fsigned-char 7 | APP_LDFLAGS := -latomic 8 | 9 | APP_ABI := armeabi 10 | # developers report it will cause error on Windows 11 | # APP_SHORT_COMMANDS := true 12 | 13 | USE_ARM_MODE := 1 14 | 15 | ifeq ($(NDK_DEBUG),1) 16 | APP_CPPFLAGS += -DCOCOS2D_DEBUG=1 17 | APP_OPTIM := debug 18 | else 19 | APP_CPPFLAGS += -DNDEBUG 20 | APP_OPTIM := release 21 | endif 22 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/jni/hellojavascript/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | #include "AppDelegate.h" 7 | 8 | #define LOG_TAG "main" 9 | #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG,LOG_TAG,__VA_ARGS__) 10 | 11 | namespace { 12 | std::unique_ptr appDelegate; 13 | } 14 | 15 | void cocos_android_app_init(JNIEnv* env) { 16 | LOGD("cocos_android_app_init"); 17 | appDelegate.reset(new AppDelegate()); 18 | } 19 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/proguard-project.txt: -------------------------------------------------------------------------------- 1 | # To enable ProGuard in your project, edit project.properties 2 | # to define the proguard.config property as described in that file. 3 | # 4 | # Add project specific ProGuard rules here. 5 | # By default, the flags in this file are appended to flags specified 6 | # in ${sdk.dir}/tools/proguard/proguard-android.txt 7 | # You can edit the include path and order by changing the ProGuard 8 | # include property in project.properties. 9 | # 10 | # For more details, see 11 | # http://developer.android.com/guide/developing/tools/proguard.html 12 | 13 | # Add any project specific keep options here: 14 | 15 | # If your project uses WebView with JS, uncomment the following 16 | # and specify the fully qualified class name to the JavaScript interface 17 | # class: 18 | #-keepclassmembers class fqcn.of.javascript.interface.for.webview { 19 | # public *; 20 | #} 21 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/project.properties: -------------------------------------------------------------------------------- 1 | # This file is automatically generated by Android Tools. 2 | # Do not modify this file -- YOUR CHANGES WILL BE ERASED! 3 | # 4 | # This file must be checked in Version Control Systems. 5 | # 6 | # To customize properties used by the Ant build system use, 7 | # "ant.properties", and override values to adapt the script to your 8 | # project structure. 9 | 10 | # Project target. 11 | target=android-13 12 | 13 | android.library.reference.1=../../cocos2d-x/cocos/platform/android/java 14 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/res/drawable-hdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android/res/drawable-hdpi/icon.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/res/drawable-ldpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android/res/drawable-ldpi/icon.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/res/drawable-mdpi/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.android/res/drawable-mdpi/icon.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/res/values/strings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | iOS_JSB 4 | 5 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.android/src/org/cocos2dx/javascript/AppActivity.java: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2008-2010 Ricardo Quesada 3 | Copyright (c) 2010-2012 cocos2d-x.org 4 | Copyright (c) 2011 Zynga Inc. 5 | Copyright (c) 2013-2017 Chukong Technologies Inc. 6 | 7 | http://www.cocos2d-x.org 8 | 9 | Permission is hereby granted, free of charge, to any person obtaining a copy 10 | of this software and associated documentation files (the "Software"), to deal 11 | in the Software without restriction, including without limitation the rights 12 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | copies of the Software, and to permit persons to whom the Software is 14 | furnished to do so, subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be included in 17 | all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 25 | THE SOFTWARE. 26 | ****************************************************************************/ 27 | package org.cocos2dx.javascript; 28 | 29 | import android.os.Bundle; 30 | import org.cocos2dx.lib.Cocos2dxActivity; 31 | import org.cocos2dx.lib.Cocos2dxGLSurfaceView; 32 | 33 | public class AppActivity extends Cocos2dxActivity { 34 | @Override 35 | protected void onCreate(Bundle savedInstanceState) { 36 | super.setEnableVirtualButton(false); 37 | super.onCreate(savedInstanceState); 38 | // Workaround in https://stackoverflow.com/questions/16283079/re-launch-of-activity-on-home-button-but-only-the-first-time/16447508 39 | if (!isTaskRoot()) { 40 | // Android launched another instance of the root activity into an existing task 41 | // so just quietly finish and go away, dropping the user back into the activity 42 | // at the top of the stack (ie: the last state of this task) 43 | // Don't need to finish it again since it's finished in super.onCreate . 44 | return; 45 | } 46 | 47 | // DO OTHER INITIALIZATION BELOW 48 | } 49 | 50 | @Override 51 | public Cocos2dxGLSurfaceView onCreateView() { 52 | Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this); 53 | // TestCpp should create stencil buffer 54 | glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8); 55 | 56 | return glSurfaceView; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/iOSBinding.h: -------------------------------------------------------------------------------- 1 | // 2 | // iOSBinding.h 3 | // iOS_JSB-mobile 4 | // 5 | // Created by BB9z on 26/01/2018. 6 | // 7 | 8 | #import 9 | 10 | void jsb_ios_load(); 11 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/iOSBinding.mm: -------------------------------------------------------------------------------- 1 | 2 | #import "iOSBinding.h" 3 | #import "JSBH.h" 4 | 5 | #pragma mark - 业务方法 6 | 7 | bool jsb_APIVersion(JSContext* cx, uint32_t argc, jsval* vp) { 8 | NSString *v = NSBundle.mainBundle.infoDictionary[@"CFBundleVersion"]; 9 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 10 | JSBH_FunctionReturnInt(v.intValue); 11 | return true; 12 | } 13 | 14 | bool demoAdd(JSContext* cx, uint32_t argc, jsval* vp) { 15 | JSBH_FunctionAssertArgcNumber(2); 16 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 17 | JSBH_FunctionAssertArgsType(0, JSTYPE_NUMBER); 18 | JSBH_FunctionAssertArgsType(1, JSTYPE_NUMBER); 19 | 20 | bool ok = false; 21 | int a; 22 | int b; 23 | ok = jsval_to_int(cx, args[0], &a); 24 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 25 | ok = jsval_to_int(cx, args[1], &b); 26 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 27 | 28 | JSBH_FunctionReturnInt(a + b); 29 | return true; 30 | } 31 | 32 | bool demoAsyncOperation(JSContext* cx, uint32_t argc, jsval* vp) { 33 | JSBH_FunctionAssertArgcNumber(2); 34 | JS::CallArgs args = JS::CallArgsFromVp(argc, vp); 35 | JSBH_FunctionAssertArgsType(0, JSTYPE_STRING); 36 | JSBH_FunctionAssertArgsType(1, JSTYPE_FUNCTION); 37 | 38 | bool ok = false; 39 | std::string input; 40 | ok = jsval_to_std_string(cx, args[0], &input); 41 | JSB_PRECONDITION2(ok, cx, false, "Error processing arguments"); 42 | 43 | JSBH_GenerateFuncCallback(1, callback, NSString *response, NSString *errCode, NSString *errMessage) { 44 | JSB_AUTOCOMPARTMENT_WITH_GLOBAL_OBJCET 45 | jsval largv[2]; 46 | largv[0] = JSBH_String(cx, response); 47 | largv[1] = JSBH_Error(cx, errCode, errMessage); 48 | JS::RootedValue rval(cx); 49 | bool succeed = func->invoke(2, &largv[0], &rval); 50 | if (!succeed && JS_IsExceptionPending(cx)) { 51 | JS_ReportPendingException(cx); 52 | } 53 | }; 54 | 55 | dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ 56 | if ([NSStringFromSTDString(input) isEqualToString:@"x"]) { 57 | callback(nil, @"TEST", @"演示错误"); 58 | return; 59 | } 60 | callback(@"After 1s response", nil, nil); 61 | }); 62 | return true; 63 | } 64 | 65 | #pragma mark - JS 暴露 66 | 67 | bool js_class_constructor(JSContext *cx, uint32_t argc, jsval *vp) { 68 | JS_ReportError(cx, "iOS 是命名空间,不支持创建对象"); 69 | return false; 70 | } 71 | 72 | void js_class_finalize(JSFreeOp *fop, JSObject *obj) { 73 | CCLOG("jsbindings: finalizing JS object %p (iOS)", obj); 74 | } 75 | 76 | JSBH_GenerateClassRegisteFunction(iOS) 77 | static JSPropertySpec properties[] = { 78 | JS_PSG("APIVersion", jsb_APIVersion, JSPROP_ENUMERATE | JSPROP_PERMANENT), 79 | JS_PS_END 80 | }; 81 | 82 | static JSFunctionSpec funcs[] = { 83 | JS_FS_END 84 | }; 85 | 86 | static JSFunctionSpec st_funcs[] = { 87 | JS_FN("demoAdd", demoAdd, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), 88 | JS_FN("demoAsyncOperation", demoAsyncOperation, 1, JSPROP_PERMANENT | JSPROP_ENUMERATE), 89 | JS_FS_END 90 | }; 91 | JSBH_GenerateClassRegisteFunctionEND(iOS) 92 | 93 | void jsb_ios_load() { 94 | ScriptingCore* sc = ScriptingCore::getInstance(); 95 | sc->addRegisterCallback(jsb_registe); 96 | } 97 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/iOSBindingInterface.js: -------------------------------------------------------------------------------- 1 | /** 2 | * iOS native 暴露给 JS 的界面 3 | * 4 | * 这只是一个例子,原生和 JS 那边的开发人员需要约定好接口,除了参数怎么传,错误处理和一些细节也应该标注 5 | */ 6 | var iOS = { 7 | 8 | /** 9 | * @property {int} - 接口版本,可用于兼容性处理 10 | */ 11 | APIVersion: 7, 12 | 13 | /** 14 | * @callback ProductsListCallback 15 | * @param {string} listJSON - JSON 字符串,商品信息的数组 16 | * @param {object} error - 错误信息,没有错误为 null 17 | * error code: 18 | * 'ILLEGAL_ARGS' 参数错误 19 | * 'SUBSTITUTED' 当前查询未完成就发起了一个新的查询,因而旧查询被替换掉。回调处理不应报错给用户。 20 | * 'TIMEOUT' 等待超时。回调处理建议提供允许用户重试的机制。 21 | * 'UNAVAILABLE' 当前设备不支持购买 22 | * 'NATIVE' native 代码发生的其它错误 23 | */ 24 | 25 | /** 26 | * 异步获取应用内购的商品列表 27 | * 28 | * 如果查询传入时有无效的 ID,返回的条数会和传参数量不一致;返回商品信息的顺序和传入 ID 顺序保持一致 29 | * 30 | * @param {string} list - 若干商品 ID,JSON 数组,数组元素是字符串 31 | * @param {ProductsListCallback} callback 操作完成回调 32 | */ 33 | IAP_requestProductsList: (list, callback) => { }, 34 | 35 | /** 36 | * @callback ProductsBuyCallback 37 | * @param {string} id - 购买商品的 ID 38 | * @param {object} error - 错误信息,没有错误为 null 39 | * error code: 40 | * 'ILLEGAL_ARGS' 参数错误 41 | * 'CANCEL' 用户取消 42 | * 'INFO_TEMPORARILY_UNAVAILABLE' 暂时找不到商品信息。建议用户重试 43 | * 'DEFERRED' 等待后台处理,暂时无法完成购买 44 | * 'NATIVE' native 代码发生的其它错误 45 | */ 46 | 47 | /** 48 | * 购买内购商品 49 | * 50 | * @param {string} id - 商品 ID 51 | * @param {string} user_id - 用户 ID 52 | * @param {ProductsBuyCallback} callback 53 | */ 54 | IAP_buyProduct: (id, user_id, callback) => { } 55 | }; 56 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/iOS_JSB.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A67682A180E9C060076BC67 /* libcocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB48180E9ACB004C840B /* libcocos2d Mac.a */; }; 11 | 1A676839180E9C1E0076BC67 /* libcocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 1AC6FB56180E9ACB004C840B /* libcocos2d iOS.a */; }; 12 | 1A82F5FB169AC92500C4B13A /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A82F5FA169AC92500C4B13A /* libsqlite3.dylib */; }; 13 | 1AC22EDE18CA0E11007112B9 /* project.json in Resources */ = {isa = PBXBuildFile; fileRef = 1A1A081B18C9DF05005C6854 /* project.json */; }; 14 | 1AD7E0A818C9DB93004817A6 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6BF21418C9DB5900FB0E1C /* main.js */; }; 15 | 1AD7E0A918C9DBE3004817A6 /* main.js in Resources */ = {isa = PBXBuildFile; fileRef = 1A6BF21418C9DB5900FB0E1C /* main.js */; }; 16 | 1AE159EC18C9DF3600FCA372 /* project.json in Resources */ = {isa = PBXBuildFile; fileRef = 1A1A081B18C9DF05005C6854 /* project.json */; }; 17 | 294D0D681D0D56F400F7F5D4 /* CoreText.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 294D0D671D0D56F400F7F5D4 /* CoreText.framework */; }; 18 | 46EFD4681F6A809E00164EE0 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 46EFD4671F6A809E00164EE0 /* GameController.framework */; }; 19 | 502380DC17EBB88200990C9B /* libcurl.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 502380DB17EBB88200990C9B /* libcurl.dylib */; }; 20 | 5091731A17ECDF7A00D62437 /* Icon-29.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731417ECDF7A00D62437 /* Icon-29.png */; }; 21 | 5091731B17ECDF7A00D62437 /* Icon-40.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731517ECDF7A00D62437 /* Icon-40.png */; }; 22 | 5091731C17ECDF7A00D62437 /* Icon-50.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731617ECDF7A00D62437 /* Icon-50.png */; }; 23 | 5091731D17ECDF7A00D62437 /* Icon-58.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731717ECDF7A00D62437 /* Icon-58.png */; }; 24 | 5091731E17ECDF7A00D62437 /* Icon-80.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731817ECDF7A00D62437 /* Icon-80.png */; }; 25 | 5091731F17ECDF7A00D62437 /* Icon-100.png in Resources */ = {isa = PBXBuildFile; fileRef = 5091731917ECDF7A00D62437 /* Icon-100.png */; }; 26 | 509D4A8117EBB24E00697056 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; 27 | 509D4A8817EBB24E00697056 /* libsqlite3.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 1A82F5FA169AC92500C4B13A /* libsqlite3.dylib */; }; 28 | 509D4A8917EBB24E00697056 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D454520B156E22BD00887EB5 /* libz.dylib */; }; 29 | 509D4A8A17EBB24E00697056 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; 30 | 509D4A8C17EBB24E00697056 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; 31 | 509D4A8D17EBB24E00697056 /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; 32 | 509D4A8E17EBB24E00697056 /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275491517C094001B78AA /* AVFoundation.framework */; }; 33 | 509D4A9017EBB24E00697056 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; 34 | 509D4A9117EBB24E00697056 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; 35 | 509D4ABC17EBB2AB00697056 /* AppController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 509D4AAC17EBB2AB00697056 /* AppController.mm */; }; 36 | 509D4ABD17EBB2AB00697056 /* Default-568h@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AAD17EBB2AB00697056 /* Default-568h@2x.png */; }; 37 | 509D4ABE17EBB2AB00697056 /* Default.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AAE17EBB2AB00697056 /* Default.png */; }; 38 | 509D4ABF17EBB2AB00697056 /* Default@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AAF17EBB2AB00697056 /* Default@2x.png */; }; 39 | 509D4AC017EBB2AB00697056 /* Icon-57.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB017EBB2AB00697056 /* Icon-57.png */; }; 40 | 509D4AC117EBB2AB00697056 /* Icon-72.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB117EBB2AB00697056 /* Icon-72.png */; }; 41 | 509D4AC217EBB2AB00697056 /* Icon-76.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB217EBB2AB00697056 /* Icon-76.png */; }; 42 | 509D4AC317EBB2AB00697056 /* Icon-114.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB317EBB2AB00697056 /* Icon-114.png */; }; 43 | 509D4AC417EBB2AB00697056 /* Icon-120.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB417EBB2AB00697056 /* Icon-120.png */; }; 44 | 509D4AC517EBB2AB00697056 /* Icon-144.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB517EBB2AB00697056 /* Icon-144.png */; }; 45 | 509D4AC617EBB2AB00697056 /* Icon-152.png in Resources */ = {isa = PBXBuildFile; fileRef = 509D4AB617EBB2AB00697056 /* Icon-152.png */; }; 46 | 509D4AC817EBB2AB00697056 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 509D4AB817EBB2AB00697056 /* main.m */; settings = {COMPILER_FLAGS = "-fno-objc-arc"; }; }; 47 | 509D4AC917EBB2AB00697056 /* RootViewController.mm in Sources */ = {isa = PBXBuildFile; fileRef = 509D4ABB17EBB2AB00697056 /* RootViewController.mm */; }; 48 | 509D4ACF17EBB2BE00697056 /* Icon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 509D4ACB17EBB2BE00697056 /* Icon.icns */; }; 49 | 509D4AE717EBB81800697056 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AE617EBB81800697056 /* OpenGL.framework */; }; 50 | 509D4AE917EBB82000697056 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AE817EBB82000697056 /* AppKit.framework */; }; 51 | 509D4AEB17EBB82600697056 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 509D4AEA17EBB82600697056 /* IOKit.framework */; }; 52 | 9FA3AE461BE9BBCA00FC9645 /* GameController.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9FA3AE451BE9BBCA00FC9645 /* GameController.framework */; }; 53 | A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275411517C094001B78AA /* QuartzCore.framework */; }; 54 | A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275431517C094001B78AA /* OpenGLES.framework */; }; 55 | A92275461517C094001B78AA /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275451517C094001B78AA /* OpenAL.framework */; }; 56 | A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275471517C094001B78AA /* AudioToolbox.framework */; }; 57 | A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A92275491517C094001B78AA /* AVFoundation.framework */; }; 58 | A922754C1517C094001B78AA /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754B1517C094001B78AA /* UIKit.framework */; }; 59 | A922754E1517C094001B78AA /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754D1517C094001B78AA /* Foundation.framework */; }; 60 | A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = A922754F1517C094001B78AA /* CoreGraphics.framework */; }; 61 | BA3A85EC1A724AE900924D24 /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA3A85EB1A724AE900924D24 /* Security.framework */; }; 62 | BA4E718119EB6E3F00932425 /* MediaPlayer.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BA4E718019EB6E3E00932425 /* MediaPlayer.framework */; }; 63 | BAEE4D841AC40C11003BEB0F /* Security.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = BAEE4D831AC40C11003BEB0F /* Security.framework */; }; 64 | BAF426FB19484B3E002B22EF /* script in Resources */ = {isa = PBXBuildFile; fileRef = BAF426FA19484B3E002B22EF /* script */; }; 65 | BAF426FC19484B3E002B22EF /* script in Resources */ = {isa = PBXBuildFile; fileRef = BAF426FA19484B3E002B22EF /* script */; }; 66 | C03780EB18BEE0E400FE4F13 /* src in Resources */ = {isa = PBXBuildFile; fileRef = C03780EA18BEE0E400FE4F13 /* src */; }; 67 | C03780EC18BEE0E400FE4F13 /* src in Resources */ = {isa = PBXBuildFile; fileRef = C03780EA18BEE0E400FE4F13 /* src */; }; 68 | C037820C18BF77C500FE4F13 /* libjscocos2d iOS.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C037820918BF76AF00FE4F13 /* libjscocos2d iOS.a */; }; 69 | C037820F18BF77DE00FE4F13 /* libjscocos2d Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = C037820718BF76AF00FE4F13 /* libjscocos2d Mac.a */; }; 70 | C06E23CC18CEFE680093C81A /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C06E23CB18CEFE680093C81A /* main.cpp */; }; 71 | C0799CB918BAE62000E9C828 /* res in Resources */ = {isa = PBXBuildFile; fileRef = C0799CB518BAE62000E9C828 /* res */; }; 72 | C0799CBA18BAE62000E9C828 /* res in Resources */ = {isa = PBXBuildFile; fileRef = C0799CB518BAE62000E9C828 /* res */; }; 73 | D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = D454520B156E22BD00887EB5 /* libz.dylib */; }; 74 | D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */ = {isa = PBXBuildFile; fileRef = D4545215156E28EF00887EB5 /* AppDelegate.cpp */; }; 75 | D50217BB201ABE8D0095B30C /* iOSBinding.mm in Sources */ = {isa = PBXBuildFile; fileRef = D50217BA201ABE8D0095B30C /* iOSBinding.mm */; }; 76 | D50217C2201B1A150095B30C /* JSBH.mm in Sources */ = {isa = PBXBuildFile; fileRef = D50217C1201B1A150095B30C /* JSBH.mm */; }; 77 | D6B061241803AB9F0077942B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B061231803AB9F0077942B /* CoreMotion.framework */; }; 78 | ED545A821B68A21500C3958E /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED545A811B68A21500C3958E /* libiconv.dylib */; }; 79 | ED545A841B68A21C00C3958E /* libiconv.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = ED545A831B68A21C00C3958E /* libiconv.dylib */; }; 80 | /* End PBXBuildFile section */ 81 | 82 | /* Begin PBXContainerItemProxy section */ 83 | 1A67681F180E9BF70076BC67 /* PBXContainerItemProxy */ = { 84 | isa = PBXContainerItemProxy; 85 | containerPortal = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 86 | proxyType = 1; 87 | remoteGlobalIDString = 1551A33E158F2AB200E66CFE; 88 | remoteInfo = "cocos2dx Mac"; 89 | }; 90 | 1A67682E180E9C110076BC67 /* PBXContainerItemProxy */ = { 91 | isa = PBXContainerItemProxy; 92 | containerPortal = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 93 | proxyType = 1; 94 | remoteGlobalIDString = A07A4C241783777C0073F6A7; 95 | remoteInfo = "cocos2dx iOS"; 96 | }; 97 | 1AC6FB47180E9ACB004C840B /* PBXContainerItemProxy */ = { 98 | isa = PBXContainerItemProxy; 99 | containerPortal = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 100 | proxyType = 2; 101 | remoteGlobalIDString = 1551A33F158F2AB200E66CFE; 102 | remoteInfo = "cocos2dx Mac"; 103 | }; 104 | 1AC6FB55180E9ACB004C840B /* PBXContainerItemProxy */ = { 105 | isa = PBXContainerItemProxy; 106 | containerPortal = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 107 | proxyType = 2; 108 | remoteGlobalIDString = A07A4D641783777C0073F6A7; 109 | remoteInfo = "cocos2dx iOS"; 110 | }; 111 | C037820618BF76AF00FE4F13 /* PBXContainerItemProxy */ = { 112 | isa = PBXContainerItemProxy; 113 | containerPortal = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 114 | proxyType = 2; 115 | remoteGlobalIDString = 1A5410A418B785A10016A3AF; 116 | remoteInfo = "jsbindings Mac"; 117 | }; 118 | C037820818BF76AF00FE4F13 /* PBXContainerItemProxy */ = { 119 | isa = PBXContainerItemProxy; 120 | containerPortal = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 121 | proxyType = 2; 122 | remoteGlobalIDString = 1A5410A518B785A10016A3AF; 123 | remoteInfo = "jsbindings iOS"; 124 | }; 125 | C037820A18BF77BC00FE4F13 /* PBXContainerItemProxy */ = { 126 | isa = PBXContainerItemProxy; 127 | containerPortal = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 128 | proxyType = 1; 129 | remoteGlobalIDString = A07A4FB5178387750073F6A7; 130 | remoteInfo = "jsbindings iOS"; 131 | }; 132 | C037820D18BF77D100FE4F13 /* PBXContainerItemProxy */ = { 133 | isa = PBXContainerItemProxy; 134 | containerPortal = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 135 | proxyType = 1; 136 | remoteGlobalIDString = A03F31E81781479B006731B9; 137 | remoteInfo = "jsbindings Mac"; 138 | }; 139 | D50217B4201ABE310095B30C /* PBXContainerItemProxy */ = { 140 | isa = PBXContainerItemProxy; 141 | containerPortal = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 142 | proxyType = 2; 143 | remoteGlobalIDString = 507B427D1C31DCC60067B53E; 144 | remoteInfo = "libjscocos2d tvOS"; 145 | }; 146 | D50217B7201ABE310095B30C /* PBXContainerItemProxy */ = { 147 | isa = PBXContainerItemProxy; 148 | containerPortal = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 149 | proxyType = 2; 150 | remoteGlobalIDString = 507B40FD1C31BDD30067B53E; 151 | remoteInfo = "libcocos2d tvOS"; 152 | }; 153 | /* End PBXContainerItemProxy section */ 154 | 155 | /* Begin PBXFileReference section */ 156 | 1A1A081B18C9DF05005C6854 /* project.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; name = project.json; path = ../../../project.json; sourceTree = ""; }; 157 | 1A6BF21418C9DB5900FB0E1C /* main.js */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.javascript; name = main.js; path = ../../../main.js; sourceTree = ""; }; 158 | 1A82F5FA169AC92500C4B13A /* libsqlite3.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libsqlite3.dylib; path = usr/lib/libsqlite3.dylib; sourceTree = SDKROOT; }; 159 | 1A96A4F2174A3432008653A9 /* libcurl.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libcurl.a; path = "../../cocos2d-x/cocos2dx/platform/third_party/ios/libraries/libcurl.a"; sourceTree = ""; }; 160 | 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_libs.xcodeproj; path = "../../cocos2d-x/build/cocos2d_libs.xcodeproj"; sourceTree = ""; }; 161 | 294D0D671D0D56F400F7F5D4 /* CoreText.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreText.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreText.framework; sourceTree = DEVELOPER_DIR; }; 162 | 46EFD4671F6A809E00164EE0 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = System/Library/Frameworks/GameController.framework; sourceTree = SDKROOT; }; 163 | 502380DB17EBB88200990C9B /* libcurl.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libcurl.dylib; path = usr/lib/libcurl.dylib; sourceTree = SDKROOT; }; 164 | 5091731417ECDF7A00D62437 /* Icon-29.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-29.png"; path = "ios/Icon-29.png"; sourceTree = ""; }; 165 | 5091731517ECDF7A00D62437 /* Icon-40.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-40.png"; path = "ios/Icon-40.png"; sourceTree = ""; }; 166 | 5091731617ECDF7A00D62437 /* Icon-50.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-50.png"; path = "ios/Icon-50.png"; sourceTree = ""; }; 167 | 5091731717ECDF7A00D62437 /* Icon-58.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-58.png"; path = "ios/Icon-58.png"; sourceTree = ""; }; 168 | 5091731817ECDF7A00D62437 /* Icon-80.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-80.png"; path = "ios/Icon-80.png"; sourceTree = ""; }; 169 | 5091731917ECDF7A00D62437 /* Icon-100.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-100.png"; path = "ios/Icon-100.png"; sourceTree = ""; }; 170 | 509D4AAA17EBB24E00697056 /* iOS_JSB-desktop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS_JSB-desktop.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 171 | 509D4AAB17EBB2AB00697056 /* AppController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppController.h; path = ios/AppController.h; sourceTree = ""; }; 172 | 509D4AAC17EBB2AB00697056 /* AppController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = AppController.mm; path = ios/AppController.mm; sourceTree = ""; }; 173 | 509D4AAD17EBB2AB00697056 /* Default-568h@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default-568h@2x.png"; path = "ios/Default-568h@2x.png"; sourceTree = ""; }; 174 | 509D4AAE17EBB2AB00697056 /* Default.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = Default.png; path = ios/Default.png; sourceTree = ""; }; 175 | 509D4AAF17EBB2AB00697056 /* Default@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Default@2x.png"; path = "ios/Default@2x.png"; sourceTree = ""; }; 176 | 509D4AB017EBB2AB00697056 /* Icon-57.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-57.png"; path = "ios/Icon-57.png"; sourceTree = ""; }; 177 | 509D4AB117EBB2AB00697056 /* Icon-72.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-72.png"; path = "ios/Icon-72.png"; sourceTree = ""; }; 178 | 509D4AB217EBB2AB00697056 /* Icon-76.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-76.png"; path = "ios/Icon-76.png"; sourceTree = ""; }; 179 | 509D4AB317EBB2AB00697056 /* Icon-114.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-114.png"; path = "ios/Icon-114.png"; sourceTree = ""; }; 180 | 509D4AB417EBB2AB00697056 /* Icon-120.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-120.png"; path = "ios/Icon-120.png"; sourceTree = ""; }; 181 | 509D4AB517EBB2AB00697056 /* Icon-144.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-144.png"; path = "ios/Icon-144.png"; sourceTree = ""; }; 182 | 509D4AB617EBB2AB00697056 /* Icon-152.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "Icon-152.png"; path = "ios/Icon-152.png"; sourceTree = ""; }; 183 | 509D4AB717EBB2AB00697056 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = ios/Info.plist; sourceTree = ""; }; 184 | 509D4AB817EBB2AB00697056 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = ios/main.m; sourceTree = ""; }; 185 | 509D4AB917EBB2AB00697056 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Prefix.pch; path = ios/Prefix.pch; sourceTree = ""; }; 186 | 509D4ABA17EBB2AB00697056 /* RootViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = RootViewController.h; path = ios/RootViewController.h; sourceTree = ""; }; 187 | 509D4ABB17EBB2AB00697056 /* RootViewController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = RootViewController.mm; path = ios/RootViewController.mm; sourceTree = ""; }; 188 | 509D4ACB17EBB2BE00697056 /* Icon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = Icon.icns; sourceTree = ""; }; 189 | 509D4ACC17EBB2BE00697056 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 190 | 509D4ACE17EBB2BE00697056 /* Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Prefix.pch; sourceTree = ""; }; 191 | 509D4AE617EBB81800697056 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; 192 | 509D4AE817EBB82000697056 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; 193 | 509D4AEA17EBB82600697056 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; }; 194 | 9FA3AE451BE9BBCA00FC9645 /* GameController.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = GameController.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/GameController.framework; sourceTree = DEVELOPER_DIR; }; 195 | A922753D1517C094001B78AA /* iOS_JSB-mobile.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "iOS_JSB-mobile.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 196 | A92275411517C094001B78AA /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; }; 197 | A92275431517C094001B78AA /* OpenGLES.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGLES.framework; path = System/Library/Frameworks/OpenGLES.framework; sourceTree = SDKROOT; }; 198 | A92275451517C094001B78AA /* OpenAL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenAL.framework; path = System/Library/Frameworks/OpenAL.framework; sourceTree = SDKROOT; }; 199 | A92275471517C094001B78AA /* AudioToolbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AudioToolbox.framework; path = System/Library/Frameworks/AudioToolbox.framework; sourceTree = SDKROOT; }; 200 | A92275491517C094001B78AA /* AVFoundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AVFoundation.framework; path = System/Library/Frameworks/AVFoundation.framework; sourceTree = SDKROOT; }; 201 | A922754B1517C094001B78AA /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 202 | A922754D1517C094001B78AA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 203 | A922754F1517C094001B78AA /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 204 | BA3A85EB1A724AE900924D24 /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/Security.framework; sourceTree = DEVELOPER_DIR; }; 205 | BA4E718019EB6E3E00932425 /* MediaPlayer.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = MediaPlayer.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/MediaPlayer.framework; sourceTree = DEVELOPER_DIR; }; 206 | BAEE4D831AC40C11003BEB0F /* Security.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Security.framework; path = System/Library/Frameworks/Security.framework; sourceTree = SDKROOT; }; 207 | BAF426FA19484B3E002B22EF /* script */ = {isa = PBXFileReference; lastKnownFileType = folder; name = script; path = "../../cocos2d-x/cocos/scripting/js-bindings/script"; sourceTree = ""; }; 208 | C03780EA18BEE0E400FE4F13 /* src */ = {isa = PBXFileReference; lastKnownFileType = folder; name = src; path = ../../../src; sourceTree = ""; }; 209 | C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = cocos2d_js_bindings.xcodeproj; path = "../../cocos2d-x/cocos/scripting/js-bindings/proj.ios_mac/cocos2d_js_bindings.xcodeproj"; sourceTree = ""; }; 210 | C06E23CB18CEFE680093C81A /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 211 | C0799CB518BAE62000E9C828 /* res */ = {isa = PBXFileReference; lastKnownFileType = folder; name = res; path = ../../../res; sourceTree = ""; }; 212 | D454520B156E22BD00887EB5 /* libz.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libz.dylib; path = usr/lib/libz.dylib; sourceTree = SDKROOT; }; 213 | D4545215156E28EF00887EB5 /* AppDelegate.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AppDelegate.cpp; sourceTree = ""; }; 214 | D4545216156E28EF00887EB5 /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 215 | D50217B9201ABE8D0095B30C /* iOSBinding.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = iOSBinding.h; sourceTree = ""; }; 216 | D50217BA201ABE8D0095B30C /* iOSBinding.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = iOSBinding.mm; sourceTree = ""; }; 217 | D50217BC201AFAF70095B30C /* JSBH.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = JSBH.h; sourceTree = ""; }; 218 | D50217BF201B12100095B30C /* iOSBindingInterface.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = iOSBindingInterface.js; sourceTree = ""; }; 219 | D50217C1201B1A150095B30C /* JSBH.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = JSBH.mm; sourceTree = ""; }; 220 | D6B061231803AB9F0077942B /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; }; 221 | ED545A811B68A21500C3958E /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/lib/libiconv.dylib; sourceTree = DEVELOPER_DIR; }; 222 | ED545A831B68A21C00C3958E /* libiconv.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; name = libiconv.dylib; path = usr/lib/libiconv.dylib; sourceTree = SDKROOT; }; 223 | /* End PBXFileReference section */ 224 | 225 | /* Begin PBXFrameworksBuildPhase section */ 226 | 509D4A8217EBB24E00697056 /* Frameworks */ = { 227 | isa = PBXFrameworksBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | 46EFD4681F6A809E00164EE0 /* GameController.framework in Frameworks */, 231 | ED545A841B68A21C00C3958E /* libiconv.dylib in Frameworks */, 232 | BAEE4D841AC40C11003BEB0F /* Security.framework in Frameworks */, 233 | C037820F18BF77DE00FE4F13 /* libjscocos2d Mac.a in Frameworks */, 234 | 1A67682A180E9C060076BC67 /* libcocos2d Mac.a in Frameworks */, 235 | 502380DC17EBB88200990C9B /* libcurl.dylib in Frameworks */, 236 | 509D4A8817EBB24E00697056 /* libsqlite3.dylib in Frameworks */, 237 | 509D4A8917EBB24E00697056 /* libz.dylib in Frameworks */, 238 | 509D4AEB17EBB82600697056 /* IOKit.framework in Frameworks */, 239 | 509D4AE917EBB82000697056 /* AppKit.framework in Frameworks */, 240 | 509D4AE717EBB81800697056 /* OpenGL.framework in Frameworks */, 241 | 509D4A8A17EBB24E00697056 /* QuartzCore.framework in Frameworks */, 242 | 509D4A8C17EBB24E00697056 /* OpenAL.framework in Frameworks */, 243 | 509D4A8D17EBB24E00697056 /* AudioToolbox.framework in Frameworks */, 244 | 509D4A8E17EBB24E00697056 /* AVFoundation.framework in Frameworks */, 245 | 509D4A9017EBB24E00697056 /* Foundation.framework in Frameworks */, 246 | 509D4A9117EBB24E00697056 /* CoreGraphics.framework in Frameworks */, 247 | ); 248 | runOnlyForDeploymentPostprocessing = 0; 249 | }; 250 | A922753A1517C094001B78AA /* Frameworks */ = { 251 | isa = PBXFrameworksBuildPhase; 252 | buildActionMask = 2147483647; 253 | files = ( 254 | 294D0D681D0D56F400F7F5D4 /* CoreText.framework in Frameworks */, 255 | 9FA3AE461BE9BBCA00FC9645 /* GameController.framework in Frameworks */, 256 | ED545A821B68A21500C3958E /* libiconv.dylib in Frameworks */, 257 | BA3A85EC1A724AE900924D24 /* Security.framework in Frameworks */, 258 | BA4E718119EB6E3F00932425 /* MediaPlayer.framework in Frameworks */, 259 | C037820C18BF77C500FE4F13 /* libjscocos2d iOS.a in Frameworks */, 260 | 1A676839180E9C1E0076BC67 /* libcocos2d iOS.a in Frameworks */, 261 | D6B061241803AB9F0077942B /* CoreMotion.framework in Frameworks */, 262 | 1A82F5FB169AC92500C4B13A /* libsqlite3.dylib in Frameworks */, 263 | D454520C156E22BD00887EB5 /* libz.dylib in Frameworks */, 264 | A92275421517C094001B78AA /* QuartzCore.framework in Frameworks */, 265 | A92275441517C094001B78AA /* OpenGLES.framework in Frameworks */, 266 | A92275461517C094001B78AA /* OpenAL.framework in Frameworks */, 267 | A92275481517C094001B78AA /* AudioToolbox.framework in Frameworks */, 268 | A922754A1517C094001B78AA /* AVFoundation.framework in Frameworks */, 269 | A922754C1517C094001B78AA /* UIKit.framework in Frameworks */, 270 | A922754E1517C094001B78AA /* Foundation.framework in Frameworks */, 271 | A92275501517C094001B78AA /* CoreGraphics.framework in Frameworks */, 272 | ); 273 | runOnlyForDeploymentPostprocessing = 0; 274 | }; 275 | /* End PBXFrameworksBuildPhase section */ 276 | 277 | /* Begin PBXGroup section */ 278 | 15628F5B15F0F5C2000CF24B /* Resources */ = { 279 | isa = PBXGroup; 280 | children = ( 281 | 1A1A081B18C9DF05005C6854 /* project.json */, 282 | 1A6BF21418C9DB5900FB0E1C /* main.js */, 283 | C0799CB518BAE62000E9C828 /* res */, 284 | C03780EA18BEE0E400FE4F13 /* src */, 285 | ); 286 | name = Resources; 287 | sourceTree = ""; 288 | }; 289 | 1AC6FB35180E9ACB004C840B /* Products */ = { 290 | isa = PBXGroup; 291 | children = ( 292 | 1AC6FB48180E9ACB004C840B /* libcocos2d Mac.a */, 293 | 1AC6FB56180E9ACB004C840B /* libcocos2d iOS.a */, 294 | D50217B8201ABE310095B30C /* libcocos2d tvOS.a */, 295 | ); 296 | name = Products; 297 | sourceTree = ""; 298 | }; 299 | 5091732E17ECDF8A00D62437 /* Icons */ = { 300 | isa = PBXGroup; 301 | children = ( 302 | 5091731417ECDF7A00D62437 /* Icon-29.png */, 303 | 5091731517ECDF7A00D62437 /* Icon-40.png */, 304 | 5091731617ECDF7A00D62437 /* Icon-50.png */, 305 | 5091731717ECDF7A00D62437 /* Icon-58.png */, 306 | 5091731817ECDF7A00D62437 /* Icon-80.png */, 307 | 5091731917ECDF7A00D62437 /* Icon-100.png */, 308 | 509D4AB017EBB2AB00697056 /* Icon-57.png */, 309 | 509D4AB117EBB2AB00697056 /* Icon-72.png */, 310 | 509D4AB217EBB2AB00697056 /* Icon-76.png */, 311 | 509D4AB317EBB2AB00697056 /* Icon-114.png */, 312 | 509D4AB417EBB2AB00697056 /* Icon-120.png */, 313 | 509D4AB517EBB2AB00697056 /* Icon-144.png */, 314 | 509D4AB617EBB2AB00697056 /* Icon-152.png */, 315 | ); 316 | name = Icons; 317 | sourceTree = ""; 318 | }; 319 | 509D4ACA17EBB2BE00697056 /* mac */ = { 320 | isa = PBXGroup; 321 | children = ( 322 | C06E23CB18CEFE680093C81A /* main.cpp */, 323 | 509D4ACB17EBB2BE00697056 /* Icon.icns */, 324 | 509D4ACC17EBB2BE00697056 /* Info.plist */, 325 | 509D4ACE17EBB2BE00697056 /* Prefix.pch */, 326 | ); 327 | path = mac; 328 | sourceTree = ""; 329 | }; 330 | A92275321517C094001B78AA = { 331 | isa = PBXGroup; 332 | children = ( 333 | C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */, 334 | 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */, 335 | BAF426FA19484B3E002B22EF /* script */, 336 | D4545214156E28EF00887EB5 /* Classes */, 337 | A92275401517C094001B78AA /* Frameworks */, 338 | D45446CC156DE73F00887EB5 /* ios */, 339 | 509D4ACA17EBB2BE00697056 /* mac */, 340 | A922753E1517C094001B78AA /* Products */, 341 | 15628F5B15F0F5C2000CF24B /* Resources */, 342 | ); 343 | sourceTree = ""; 344 | }; 345 | A922753E1517C094001B78AA /* Products */ = { 346 | isa = PBXGroup; 347 | children = ( 348 | A922753D1517C094001B78AA /* iOS_JSB-mobile.app */, 349 | 509D4AAA17EBB24E00697056 /* iOS_JSB-desktop.app */, 350 | ); 351 | name = Products; 352 | sourceTree = ""; 353 | }; 354 | A92275401517C094001B78AA /* Frameworks */ = { 355 | isa = PBXGroup; 356 | children = ( 357 | 509D4AE817EBB82000697056 /* AppKit.framework */, 358 | A92275471517C094001B78AA /* AudioToolbox.framework */, 359 | A92275491517C094001B78AA /* AVFoundation.framework */, 360 | A922754F1517C094001B78AA /* CoreGraphics.framework */, 361 | D6B061231803AB9F0077942B /* CoreMotion.framework */, 362 | 294D0D671D0D56F400F7F5D4 /* CoreText.framework */, 363 | A922754D1517C094001B78AA /* Foundation.framework */, 364 | 46EFD4671F6A809E00164EE0 /* GameController.framework */, 365 | 9FA3AE451BE9BBCA00FC9645 /* GameController.framework */, 366 | 509D4AEA17EBB82600697056 /* IOKit.framework */, 367 | 1A96A4F2174A3432008653A9 /* libcurl.a */, 368 | 502380DB17EBB88200990C9B /* libcurl.dylib */, 369 | ED545A831B68A21C00C3958E /* libiconv.dylib */, 370 | ED545A811B68A21500C3958E /* libiconv.dylib */, 371 | 1A82F5FA169AC92500C4B13A /* libsqlite3.dylib */, 372 | D454520B156E22BD00887EB5 /* libz.dylib */, 373 | BA4E718019EB6E3E00932425 /* MediaPlayer.framework */, 374 | A92275451517C094001B78AA /* OpenAL.framework */, 375 | 509D4AE617EBB81800697056 /* OpenGL.framework */, 376 | A92275431517C094001B78AA /* OpenGLES.framework */, 377 | A92275411517C094001B78AA /* QuartzCore.framework */, 378 | BAEE4D831AC40C11003BEB0F /* Security.framework */, 379 | BA3A85EB1A724AE900924D24 /* Security.framework */, 380 | A922754B1517C094001B78AA /* UIKit.framework */, 381 | ); 382 | name = Frameworks; 383 | sourceTree = ""; 384 | }; 385 | C037820218BF76AF00FE4F13 /* Products */ = { 386 | isa = PBXGroup; 387 | children = ( 388 | C037820718BF76AF00FE4F13 /* libjscocos2d Mac.a */, 389 | C037820918BF76AF00FE4F13 /* libjscocos2d iOS.a */, 390 | D50217B5201ABE310095B30C /* libjscocos2d tvOS.a */, 391 | ); 392 | name = Products; 393 | sourceTree = ""; 394 | }; 395 | D45446CC156DE73F00887EB5 /* ios */ = { 396 | isa = PBXGroup; 397 | children = ( 398 | 509D4AAB17EBB2AB00697056 /* AppController.h */, 399 | 509D4AAC17EBB2AB00697056 /* AppController.mm */, 400 | 509D4AAD17EBB2AB00697056 /* Default-568h@2x.png */, 401 | 509D4AAE17EBB2AB00697056 /* Default.png */, 402 | 509D4AAF17EBB2AB00697056 /* Default@2x.png */, 403 | 5091732E17ECDF8A00D62437 /* Icons */, 404 | 509D4AB717EBB2AB00697056 /* Info.plist */, 405 | 509D4AB817EBB2AB00697056 /* main.m */, 406 | 509D4AB917EBB2AB00697056 /* Prefix.pch */, 407 | 509D4ABA17EBB2AB00697056 /* RootViewController.h */, 408 | 509D4ABB17EBB2AB00697056 /* RootViewController.mm */, 409 | D50217B9201ABE8D0095B30C /* iOSBinding.h */, 410 | D50217BA201ABE8D0095B30C /* iOSBinding.mm */, 411 | D50217BF201B12100095B30C /* iOSBindingInterface.js */, 412 | ); 413 | name = ios; 414 | sourceTree = ""; 415 | }; 416 | D4545214156E28EF00887EB5 /* Classes */ = { 417 | isa = PBXGroup; 418 | children = ( 419 | D4545215156E28EF00887EB5 /* AppDelegate.cpp */, 420 | D4545216156E28EF00887EB5 /* AppDelegate.h */, 421 | D50217BC201AFAF70095B30C /* JSBH.h */, 422 | D50217C1201B1A150095B30C /* JSBH.mm */, 423 | ); 424 | name = Classes; 425 | path = ../Classes; 426 | sourceTree = ""; 427 | }; 428 | /* End PBXGroup section */ 429 | 430 | /* Begin PBXNativeTarget section */ 431 | 509D4A7517EBB24E00697056 /* iOS_JSB-desktop */ = { 432 | isa = PBXNativeTarget; 433 | buildConfigurationList = 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "iOS_JSB-desktop" */; 434 | buildPhases = ( 435 | 509D4A8017EBB24E00697056 /* Sources */, 436 | 509D4A9317EBB24E00697056 /* Resources */, 437 | 509D4A8217EBB24E00697056 /* Frameworks */, 438 | ); 439 | buildRules = ( 440 | ); 441 | dependencies = ( 442 | C037820E18BF77D100FE4F13 /* PBXTargetDependency */, 443 | 1A676820180E9BF70076BC67 /* PBXTargetDependency */, 444 | ); 445 | name = "iOS_JSB-desktop"; 446 | productName = iOS_JSB; 447 | productReference = 509D4AAA17EBB24E00697056 /* iOS_JSB-desktop.app */; 448 | productType = "com.apple.product-type.application"; 449 | }; 450 | A922753C1517C094001B78AA /* iOS_JSB-mobile */ = { 451 | isa = PBXNativeTarget; 452 | buildConfigurationList = A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "iOS_JSB-mobile" */; 453 | buildPhases = ( 454 | A92275391517C094001B78AA /* Sources */, 455 | A922753A1517C094001B78AA /* Frameworks */, 456 | A922753B1517C094001B78AA /* Resources */, 457 | ); 458 | buildRules = ( 459 | ); 460 | dependencies = ( 461 | C037820B18BF77BC00FE4F13 /* PBXTargetDependency */, 462 | 1A67682F180E9C110076BC67 /* PBXTargetDependency */, 463 | ); 464 | name = "iOS_JSB-mobile"; 465 | productName = iOS_JSB; 466 | productReference = A922753D1517C094001B78AA /* iOS_JSB-mobile.app */; 467 | productType = "com.apple.product-type.application"; 468 | }; 469 | /* End PBXNativeTarget section */ 470 | 471 | /* Begin PBXProject section */ 472 | A92275341517C094001B78AA /* Project object */ = { 473 | isa = PBXProject; 474 | attributes = { 475 | LastUpgradeCheck = 0500; 476 | TargetAttributes = { 477 | A922753C1517C094001B78AA = { 478 | SystemCapabilities = { 479 | com.apple.InAppPurchase = { 480 | enabled = 1; 481 | }; 482 | }; 483 | }; 484 | }; 485 | }; 486 | buildConfigurationList = A92275371517C094001B78AA /* Build configuration list for PBXProject "iOS_JSB" */; 487 | compatibilityVersion = "Xcode 3.2"; 488 | developmentRegion = English; 489 | hasScannedForEncodings = 0; 490 | knownRegions = ( 491 | en, 492 | ); 493 | mainGroup = A92275321517C094001B78AA; 494 | productRefGroup = A922753E1517C094001B78AA /* Products */; 495 | projectDirPath = ""; 496 | projectReferences = ( 497 | { 498 | ProductGroup = C037820218BF76AF00FE4F13 /* Products */; 499 | ProjectRef = C037820118BF76AF00FE4F13 /* cocos2d_js_bindings.xcodeproj */; 500 | }, 501 | { 502 | ProductGroup = 1AC6FB35180E9ACB004C840B /* Products */; 503 | ProjectRef = 1AC6FB34180E9ACB004C840B /* cocos2d_libs.xcodeproj */; 504 | }, 505 | ); 506 | projectRoot = ""; 507 | targets = ( 508 | A922753C1517C094001B78AA /* iOS_JSB-mobile */, 509 | 509D4A7517EBB24E00697056 /* iOS_JSB-desktop */, 510 | ); 511 | }; 512 | /* End PBXProject section */ 513 | 514 | /* Begin PBXReferenceProxy section */ 515 | 1AC6FB48180E9ACB004C840B /* libcocos2d Mac.a */ = { 516 | isa = PBXReferenceProxy; 517 | fileType = archive.ar; 518 | path = "libcocos2d Mac.a"; 519 | remoteRef = 1AC6FB47180E9ACB004C840B /* PBXContainerItemProxy */; 520 | sourceTree = BUILT_PRODUCTS_DIR; 521 | }; 522 | 1AC6FB56180E9ACB004C840B /* libcocos2d iOS.a */ = { 523 | isa = PBXReferenceProxy; 524 | fileType = archive.ar; 525 | path = "libcocos2d iOS.a"; 526 | remoteRef = 1AC6FB55180E9ACB004C840B /* PBXContainerItemProxy */; 527 | sourceTree = BUILT_PRODUCTS_DIR; 528 | }; 529 | C037820718BF76AF00FE4F13 /* libjscocos2d Mac.a */ = { 530 | isa = PBXReferenceProxy; 531 | fileType = archive.ar; 532 | path = "libjscocos2d Mac.a"; 533 | remoteRef = C037820618BF76AF00FE4F13 /* PBXContainerItemProxy */; 534 | sourceTree = BUILT_PRODUCTS_DIR; 535 | }; 536 | C037820918BF76AF00FE4F13 /* libjscocos2d iOS.a */ = { 537 | isa = PBXReferenceProxy; 538 | fileType = archive.ar; 539 | path = "libjscocos2d iOS.a"; 540 | remoteRef = C037820818BF76AF00FE4F13 /* PBXContainerItemProxy */; 541 | sourceTree = BUILT_PRODUCTS_DIR; 542 | }; 543 | D50217B5201ABE310095B30C /* libjscocos2d tvOS.a */ = { 544 | isa = PBXReferenceProxy; 545 | fileType = archive.ar; 546 | path = "libjscocos2d tvOS.a"; 547 | remoteRef = D50217B4201ABE310095B30C /* PBXContainerItemProxy */; 548 | sourceTree = BUILT_PRODUCTS_DIR; 549 | }; 550 | D50217B8201ABE310095B30C /* libcocos2d tvOS.a */ = { 551 | isa = PBXReferenceProxy; 552 | fileType = archive.ar; 553 | path = "libcocos2d tvOS.a"; 554 | remoteRef = D50217B7201ABE310095B30C /* PBXContainerItemProxy */; 555 | sourceTree = BUILT_PRODUCTS_DIR; 556 | }; 557 | /* End PBXReferenceProxy section */ 558 | 559 | /* Begin PBXResourcesBuildPhase section */ 560 | 509D4A9317EBB24E00697056 /* Resources */ = { 561 | isa = PBXResourcesBuildPhase; 562 | buildActionMask = 2147483647; 563 | files = ( 564 | 1AC22EDE18CA0E11007112B9 /* project.json in Resources */, 565 | 1AD7E0A918C9DBE3004817A6 /* main.js in Resources */, 566 | C0799CBA18BAE62000E9C828 /* res in Resources */, 567 | BAF426FC19484B3E002B22EF /* script in Resources */, 568 | 509D4ACF17EBB2BE00697056 /* Icon.icns in Resources */, 569 | C03780EC18BEE0E400FE4F13 /* src in Resources */, 570 | ); 571 | runOnlyForDeploymentPostprocessing = 0; 572 | }; 573 | A922753B1517C094001B78AA /* Resources */ = { 574 | isa = PBXResourcesBuildPhase; 575 | buildActionMask = 2147483647; 576 | files = ( 577 | BAF426FB19484B3E002B22EF /* script in Resources */, 578 | 1AE159EC18C9DF3600FCA372 /* project.json in Resources */, 579 | 1AD7E0A818C9DB93004817A6 /* main.js in Resources */, 580 | 509D4ABE17EBB2AB00697056 /* Default.png in Resources */, 581 | 5091731E17ECDF7A00D62437 /* Icon-80.png in Resources */, 582 | 5091731F17ECDF7A00D62437 /* Icon-100.png in Resources */, 583 | 509D4AC117EBB2AB00697056 /* Icon-72.png in Resources */, 584 | 509D4AC017EBB2AB00697056 /* Icon-57.png in Resources */, 585 | 5091731A17ECDF7A00D62437 /* Icon-29.png in Resources */, 586 | C03780EB18BEE0E400FE4F13 /* src in Resources */, 587 | 509D4AC617EBB2AB00697056 /* Icon-152.png in Resources */, 588 | C0799CB918BAE62000E9C828 /* res in Resources */, 589 | 509D4AC517EBB2AB00697056 /* Icon-144.png in Resources */, 590 | 509D4AC317EBB2AB00697056 /* Icon-114.png in Resources */, 591 | 509D4ABD17EBB2AB00697056 /* Default-568h@2x.png in Resources */, 592 | 509D4ABF17EBB2AB00697056 /* Default@2x.png in Resources */, 593 | 509D4AC217EBB2AB00697056 /* Icon-76.png in Resources */, 594 | 5091731B17ECDF7A00D62437 /* Icon-40.png in Resources */, 595 | 5091731C17ECDF7A00D62437 /* Icon-50.png in Resources */, 596 | 509D4AC417EBB2AB00697056 /* Icon-120.png in Resources */, 597 | 5091731D17ECDF7A00D62437 /* Icon-58.png in Resources */, 598 | ); 599 | runOnlyForDeploymentPostprocessing = 0; 600 | }; 601 | /* End PBXResourcesBuildPhase section */ 602 | 603 | /* Begin PBXSourcesBuildPhase section */ 604 | 509D4A8017EBB24E00697056 /* Sources */ = { 605 | isa = PBXSourcesBuildPhase; 606 | buildActionMask = 2147483647; 607 | files = ( 608 | 509D4A8117EBB24E00697056 /* AppDelegate.cpp in Sources */, 609 | C06E23CC18CEFE680093C81A /* main.cpp in Sources */, 610 | ); 611 | runOnlyForDeploymentPostprocessing = 0; 612 | }; 613 | A92275391517C094001B78AA /* Sources */ = { 614 | isa = PBXSourcesBuildPhase; 615 | buildActionMask = 2147483647; 616 | files = ( 617 | 509D4AC917EBB2AB00697056 /* RootViewController.mm in Sources */, 618 | D50217C2201B1A150095B30C /* JSBH.mm in Sources */, 619 | D50217BB201ABE8D0095B30C /* iOSBinding.mm in Sources */, 620 | D4545227156E28EF00887EB5 /* AppDelegate.cpp in Sources */, 621 | 509D4AC817EBB2AB00697056 /* main.m in Sources */, 622 | 509D4ABC17EBB2AB00697056 /* AppController.mm in Sources */, 623 | ); 624 | runOnlyForDeploymentPostprocessing = 0; 625 | }; 626 | /* End PBXSourcesBuildPhase section */ 627 | 628 | /* Begin PBXTargetDependency section */ 629 | 1A676820180E9BF70076BC67 /* PBXTargetDependency */ = { 630 | isa = PBXTargetDependency; 631 | name = "cocos2dx Mac"; 632 | targetProxy = 1A67681F180E9BF70076BC67 /* PBXContainerItemProxy */; 633 | }; 634 | 1A67682F180E9C110076BC67 /* PBXTargetDependency */ = { 635 | isa = PBXTargetDependency; 636 | name = "cocos2dx iOS"; 637 | targetProxy = 1A67682E180E9C110076BC67 /* PBXContainerItemProxy */; 638 | }; 639 | C037820B18BF77BC00FE4F13 /* PBXTargetDependency */ = { 640 | isa = PBXTargetDependency; 641 | name = "jsbindings iOS"; 642 | targetProxy = C037820A18BF77BC00FE4F13 /* PBXContainerItemProxy */; 643 | }; 644 | C037820E18BF77D100FE4F13 /* PBXTargetDependency */ = { 645 | isa = PBXTargetDependency; 646 | name = "jsbindings Mac"; 647 | targetProxy = C037820D18BF77D100FE4F13 /* PBXContainerItemProxy */; 648 | }; 649 | /* End PBXTargetDependency section */ 650 | 651 | /* Begin XCBuildConfiguration section */ 652 | 509D4AA817EBB24E00697056 /* Debug */ = { 653 | isa = XCBuildConfiguration; 654 | buildSettings = { 655 | ALWAYS_SEARCH_USER_PATHS = YES; 656 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 657 | COMBINE_HIDPI_IMAGES = YES; 658 | DEAD_CODE_STRIPPING = YES; 659 | GCC_DYNAMIC_NO_PIC = NO; 660 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 661 | GCC_PREFIX_HEADER = mac/Prefix.pch; 662 | GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; 663 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 664 | HEADER_SEARCH_PATHS = ""; 665 | INFOPLIST_FILE = mac/Info.plist; 666 | LIBRARY_SEARCH_PATHS = ""; 667 | OTHER_LDFLAGS = ""; 668 | SDKROOT = macosx; 669 | USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/external/glfw3/include/mac $(SRCROOT)/../../cocos2d-x/external/spidermonkey/include/mac"; 670 | }; 671 | name = Debug; 672 | }; 673 | 509D4AA917EBB24E00697056 /* Release */ = { 674 | isa = XCBuildConfiguration; 675 | buildSettings = { 676 | ALWAYS_SEARCH_USER_PATHS = YES; 677 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 678 | COMBINE_HIDPI_IMAGES = YES; 679 | DEAD_CODE_STRIPPING = YES; 680 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 681 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 682 | GCC_PREFIX_HEADER = mac/Prefix.pch; 683 | GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; 684 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 685 | HEADER_SEARCH_PATHS = ""; 686 | INFOPLIST_FILE = mac/Info.plist; 687 | LIBRARY_SEARCH_PATHS = ""; 688 | OTHER_LDFLAGS = ""; 689 | SDKROOT = macosx; 690 | USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/external/glfw3/include/mac $(SRCROOT)/../../cocos2d-x/external/spidermonkey/include/mac"; 691 | }; 692 | name = Release; 693 | }; 694 | A92276FE1517C097001B78AA /* Debug */ = { 695 | isa = XCBuildConfiguration; 696 | buildSettings = { 697 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 698 | CLANG_CXX_LIBRARY = "libc++"; 699 | CLANG_ENABLE_OBJC_ARC = YES; 700 | COPY_PHASE_STRIP = NO; 701 | GCC_C_LANGUAGE_STANDARD = c99; 702 | GCC_OPTIMIZATION_LEVEL = 0; 703 | GCC_PREPROCESSOR_DEFINITIONS = ( 704 | "COCOS2D_DEBUG=1", 705 | USE_FILE32API, 706 | COCOS2D_JAVASCRIPT, 707 | CC_ENABLE_CHIPMUNK_INTEGRATION, 708 | ); 709 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 710 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 711 | GCC_WARN_UNUSED_VARIABLE = YES; 712 | HEADER_SEARCH_PATHS = ""; 713 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 714 | MACOSX_DEPLOYMENT_TARGET = 10.8; 715 | ONLY_ACTIVE_ARCH = YES; 716 | PRODUCT_NAME = "$(TARGET_NAME)"; 717 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/editor-support"; 718 | }; 719 | name = Debug; 720 | }; 721 | A92276FF1517C097001B78AA /* Release */ = { 722 | isa = XCBuildConfiguration; 723 | buildSettings = { 724 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 725 | CLANG_CXX_LIBRARY = "libc++"; 726 | CLANG_ENABLE_OBJC_ARC = YES; 727 | GCC_C_LANGUAGE_STANDARD = c99; 728 | GCC_PREPROCESSOR_DEFINITIONS = ( 729 | NDEBUG, 730 | USE_FILE32API, 731 | COCOS2D_JAVASCRIPT, 732 | CC_ENABLE_CHIPMUNK_INTEGRATION, 733 | ); 734 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 735 | GCC_WARN_UNUSED_VARIABLE = YES; 736 | HEADER_SEARCH_PATHS = ""; 737 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 738 | MACOSX_DEPLOYMENT_TARGET = 10.8; 739 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 740 | PRODUCT_NAME = "$(TARGET_NAME)"; 741 | USER_HEADER_SEARCH_PATHS = "$(SRCROOT)/../../cocos2d-x $(SRCROOT)/../../cocos2d-x/cocos/audio/include $(SRCROOT)/../../cocos2d-x/cocos $(SRCROOT)/../../cocos2d-x/extensions $(SRCROOT)/../../cocos2d-x/external $(SRCROOT)/../../cocos2d-x/external/chipmunk/include/chipmunk $(SRCROOT)/../../cocos2d-x/cocos/editor-support"; 742 | VALIDATE_PRODUCT = YES; 743 | }; 744 | name = Release; 745 | }; 746 | A92277011517C097001B78AA /* Debug */ = { 747 | isa = XCBuildConfiguration; 748 | buildSettings = { 749 | ALWAYS_SEARCH_USER_PATHS = YES; 750 | CODE_SIGN_IDENTITY = "iPhone Developer"; 751 | COMPRESS_PNG_FILES = NO; 752 | DEVELOPMENT_TEAM = ""; 753 | ENABLE_BITCODE = NO; 754 | GCC_DYNAMIC_NO_PIC = NO; 755 | GCC_GENERATE_DEBUGGING_SYMBOLS = YES; 756 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 757 | GCC_PREFIX_HEADER = ios/Prefix.pch; 758 | GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; 759 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 760 | HEADER_SEARCH_PATHS = ""; 761 | INFOPLIST_FILE = ios/Info.plist; 762 | LIBRARY_SEARCH_PATHS = ""; 763 | OTHER_LDFLAGS = ""; 764 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.bb9z.cocos2d-jsb-demo"; 765 | SDKROOT = iphoneos; 766 | STRIP_PNG_TEXT = NO; 767 | TARGETED_DEVICE_FAMILY = "1,2"; 768 | USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/external/spidermonkey/include/ios $(SRCROOT)/../../cocos2d-x/plugin/jsbindings/auto $(SRCROOT)/../../cocos2d-x/plugin/jsbindings/manual $(SRCROOT)/../../cocos2d-x/cocos"; 769 | }; 770 | name = Debug; 771 | }; 772 | A92277021517C097001B78AA /* Release */ = { 773 | isa = XCBuildConfiguration; 774 | buildSettings = { 775 | ALWAYS_SEARCH_USER_PATHS = YES; 776 | CODE_SIGN_IDENTITY = "iPhone Developer"; 777 | COMPRESS_PNG_FILES = NO; 778 | DEVELOPMENT_TEAM = ""; 779 | ENABLE_BITCODE = NO; 780 | GCC_GENERATE_DEBUGGING_SYMBOLS = NO; 781 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 782 | GCC_PREFIX_HEADER = ios/Prefix.pch; 783 | GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; 784 | GCC_SYMBOLS_PRIVATE_EXTERN = YES; 785 | HEADER_SEARCH_PATHS = ""; 786 | INFOPLIST_FILE = ios/Info.plist; 787 | LIBRARY_SEARCH_PATHS = ""; 788 | OTHER_LDFLAGS = ""; 789 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.bb9z.cocos2d-jsb-demo"; 790 | SDKROOT = iphoneos; 791 | STRIP_PNG_TEXT = NO; 792 | TARGETED_DEVICE_FAMILY = "1,2"; 793 | USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/../../cocos2d-x/external/spidermonkey/include/ios $(SRCROOT)/../../cocos2d-x/plugin/jsbindings/auto $(SRCROOT)/../../cocos2d-x/plugin/jsbindings/manual $(SRCROOT)/../../cocos2d-x/cocos"; 794 | }; 795 | name = Release; 796 | }; 797 | /* End XCBuildConfiguration section */ 798 | 799 | /* Begin XCConfigurationList section */ 800 | 509D4AA717EBB24E00697056 /* Build configuration list for PBXNativeTarget "iOS_JSB-desktop" */ = { 801 | isa = XCConfigurationList; 802 | buildConfigurations = ( 803 | 509D4AA817EBB24E00697056 /* Debug */, 804 | 509D4AA917EBB24E00697056 /* Release */, 805 | ); 806 | defaultConfigurationIsVisible = 0; 807 | defaultConfigurationName = Release; 808 | }; 809 | A92275371517C094001B78AA /* Build configuration list for PBXProject "iOS_JSB" */ = { 810 | isa = XCConfigurationList; 811 | buildConfigurations = ( 812 | A92276FE1517C097001B78AA /* Debug */, 813 | A92276FF1517C097001B78AA /* Release */, 814 | ); 815 | defaultConfigurationIsVisible = 0; 816 | defaultConfigurationName = Release; 817 | }; 818 | A92277001517C097001B78AA /* Build configuration list for PBXNativeTarget "iOS_JSB-mobile" */ = { 819 | isa = XCConfigurationList; 820 | buildConfigurations = ( 821 | A92277011517C097001B78AA /* Debug */, 822 | A92277021517C097001B78AA /* Release */, 823 | ); 824 | defaultConfigurationIsVisible = 0; 825 | defaultConfigurationName = Release; 826 | }; 827 | /* End XCConfigurationList section */ 828 | }; 829 | rootObject = A92275341517C094001B78AA /* Project object */; 830 | } 831 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/iOS_JSB.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/AppController.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010-2013 cocos2d-x.org 3 | Copyright (c) 2013-2017 Chukong Technologies Inc. 4 | 5 | http://www.cocos2d-x.org 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | ****************************************************************************/ 25 | 26 | #import 27 | 28 | @class RootViewController; 29 | 30 | @interface AppController : NSObject { 31 | 32 | } 33 | 34 | @property(nonatomic, readonly) RootViewController* viewController; 35 | 36 | @end 37 | 38 | 39 | @interface AppController (JSB) 40 | 41 | /** 42 | 把一个 , 分割的字符串列表反转 43 | 44 | @code 45 | [AppController demoReverseListString:@"foo,bar,apple,tree"]; 46 | // tree,apple,bar,foo 47 | @endcode 48 | */ 49 | + (NSString *)demoReverseListString:(NSString *)string; 50 | 51 | @end 52 | 53 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/AppController.mm: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010-2013 cocos2d-x.org 3 | Copyright (c) 2013-2017 Chukong Technologies Inc. 4 | 5 | http://www.cocos2d-x.org 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | ****************************************************************************/ 25 | 26 | #import "AppController.h" 27 | #import "cocos2d.h" 28 | #import "AppDelegate.h" 29 | #import "RootViewController.h" 30 | #import "iOSBinding.h" 31 | 32 | @implementation AppController 33 | 34 | @synthesize window; 35 | 36 | #pragma mark - 37 | #pragma mark Application lifecycle 38 | 39 | // cocos2d application instance 40 | static AppDelegate s_sharedApplication; 41 | 42 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 43 | jsb_ios_load(); 44 | cocos2d::Application *app = cocos2d::Application::getInstance(); 45 | 46 | // Initialize the GLView attributes 47 | app->initGLContextAttrs(); 48 | cocos2d::GLViewImpl::convertAttrs(); 49 | 50 | // Override point for customization after application launch. 51 | 52 | // Add the view controller's view to the window and display. 53 | window = [[UIWindow alloc] initWithFrame: [[UIScreen mainScreen] bounds]]; 54 | 55 | // Use RootViewController to manage CCEAGLView 56 | _viewController = [[RootViewController alloc]init]; 57 | _viewController.wantsFullScreenLayout = YES; 58 | 59 | 60 | // Set RootViewController to window 61 | if ( [[UIDevice currentDevice].systemVersion floatValue] < 6.0) 62 | { 63 | // warning: addSubView doesn't work on iOS6 64 | [window addSubview: _viewController.view]; 65 | } 66 | else 67 | { 68 | // use this method on ios6 69 | [window setRootViewController:_viewController]; 70 | } 71 | 72 | [window makeKeyAndVisible]; 73 | 74 | [[UIApplication sharedApplication] setStatusBarHidden:true]; 75 | 76 | // IMPORTANT: Setting the GLView should be done after creating the RootViewController 77 | cocos2d::GLView *glview = cocos2d::GLViewImpl::createWithEAGLView((__bridge void *)_viewController.view); 78 | cocos2d::Director::getInstance()->setOpenGLView(glview); 79 | 80 | //run the cocos2d-x game scene 81 | app->run(); 82 | 83 | return YES; 84 | } 85 | 86 | 87 | - (void)applicationWillResignActive:(UIApplication *)application { 88 | /* 89 | 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. 90 | 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. 91 | */ 92 | // We don't need to call this method any more. It will interrupt user defined game pause&resume logic 93 | /* cocos2d::Director::getInstance()->pause(); */ 94 | } 95 | 96 | - (void)applicationDidBecomeActive:(UIApplication *)application { 97 | /* 98 | 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. 99 | */ 100 | // We don't need to call this method any more. It will interrupt user defined game pause&resume logic 101 | /* cocos2d::Director::getInstance()->resume(); */ 102 | } 103 | 104 | - (void)applicationDidEnterBackground:(UIApplication *)application { 105 | /* 106 | 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. 107 | If your application supports background execution, called instead of applicationWillTerminate: when the user quits. 108 | */ 109 | cocos2d::Application::getInstance()->applicationDidEnterBackground(); 110 | } 111 | 112 | - (void)applicationWillEnterForeground:(UIApplication *)application { 113 | /* 114 | 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. 115 | */ 116 | cocos2d::Application::getInstance()->applicationWillEnterForeground(); 117 | } 118 | 119 | - (void)applicationWillTerminate:(UIApplication *)application { 120 | /* 121 | Called when the application is about to terminate. 122 | See also applicationDidEnterBackground:. 123 | */ 124 | } 125 | 126 | 127 | #pragma mark - 128 | #pragma mark Memory management 129 | 130 | - (void)applicationDidReceiveMemoryWarning:(UIApplication *)application { 131 | /* 132 | Free up as much memory as possible by purging cached data objects that can be recreated (or reloaded from disk) later. 133 | */ 134 | } 135 | 136 | @end 137 | 138 | /// 还是为了简便,直接在 AppController 上添加静态方法 139 | #pragma mark - JSB 140 | 141 | #import "JSBH.h" 142 | 143 | @implementation AppController (JSB) 144 | 145 | + (NSString *)demoReverseListString:(NSString *)string { 146 | NSString *separator = @","; 147 | NSArray *list = [string componentsSeparatedByString:separator]; 148 | if (list.count <= 1) return string.copy; 149 | 150 | NSMutableArray *reversedList = [NSMutableArray arrayWithCapacity:list.count]; 151 | for (NSString *p in list.reverseObjectEnumerator) { 152 | [reversedList addObject:p]; 153 | } 154 | return [reversedList componentsJoinedByString:separator]; 155 | } 156 | 157 | // 展示通过 ScriptingCore 调研 JS 方法 158 | + (void)demoScriptingCore { 159 | JSBH_EvalJSStringWithoutReturn(@"console.log('🔷 print via native')"); 160 | NSString *r = JSBH_EvalJSStringReturnString(@"new Date().toLocaleString()"); 161 | NSLog(@"JS return current time: %@", r); 162 | } 163 | 164 | @end 165 | 166 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Default-568h@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Default-568h@2x.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Default-736h@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Default-736h@3x.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Default.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Default@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Default@2x.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-100.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-114.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-114.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-120.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-120.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-144.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-144.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-152.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-152.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-180.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-180.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-29.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-40.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-50.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-57.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-57.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-58.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-58.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-72.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-76.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-80.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-80.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Icon-87.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/ios/Icon-87.png -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | English 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIconFile 12 | Icon-57.png 13 | CFBundleIconFiles 14 | 15 | Icon-29 16 | Icon-40 17 | Icon-50 18 | Icon-57 19 | Icon-58 20 | Icon-72 21 | Icon-76 22 | Icon-80 23 | Icon-87 24 | Icon-100 25 | Icon-114 26 | Icon-120 27 | Icon-144 28 | Icon-152 29 | Icon-180 30 | 31 | CFBundleIconFiles~ipad 32 | 33 | Icon-29 34 | Icon-40 35 | Icon-50 36 | Icon-57 37 | Icon-58 38 | Icon-72 39 | Icon-76 40 | Icon-80 41 | Icon-87 42 | Icon-100 43 | Icon-114 44 | Icon-120 45 | Icon-144 46 | Icon-152 47 | Icon-180 48 | 49 | CFBundleIdentifier 50 | $(PRODUCT_BUNDLE_IDENTIFIER) 51 | CFBundleInfoDictionaryVersion 52 | 6.0 53 | CFBundleName 54 | ${PRODUCT_NAME} 55 | CFBundlePackageType 56 | APPL 57 | CFBundleShortVersionString 58 | 1.0 59 | CFBundleSignature 60 | ???? 61 | CFBundleVersion 62 | 1220 63 | LSRequiresIPhoneOS 64 | 65 | UIPrerenderedIcon 66 | 67 | UIRequiredDeviceCapabilities 68 | 69 | accelerometer 70 | 71 | opengles-1 72 | 73 | 74 | UIStatusBarHidden 75 | 76 | UISupportedInterfaceOrientations 77 | 78 | UIInterfaceOrientationLandscapeRight 79 | UIInterfaceOrientationLandscapeLeft 80 | 81 | 82 | 83 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'iOS_JSB' target in the 'iOS_JSB' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #import 8 | #endif 9 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/RootViewController.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2013 cocos2d-x.org 3 | Copyright (c) 2013-2017 Chukong Technologies Inc. 4 | 5 | http://www.cocos2d-x.org 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | ****************************************************************************/ 25 | 26 | #import 27 | 28 | 29 | @interface RootViewController : UIViewController { 30 | 31 | } 32 | - (BOOL) prefersStatusBarHidden; 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/RootViewController.mm: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2013 cocos2d-x.org 3 | Copyright (c) 2013-2017 Chukong Technologies Inc. 4 | 5 | http://www.cocos2d-x.org 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 23 | THE SOFTWARE. 24 | ****************************************************************************/ 25 | 26 | #import "RootViewController.h" 27 | #import "cocos2d.h" 28 | #import "platform/ios/CCEAGLView-ios.h" 29 | 30 | 31 | @implementation RootViewController 32 | 33 | /* 34 | // The designated initializer. Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad. 35 | - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { 36 | if ((self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil])) { 37 | // Custom initialization 38 | } 39 | return self; 40 | } 41 | */ 42 | 43 | // Implement loadView to create a view hierarchy programmatically, without using a nib. 44 | - (void)loadView { 45 | // Initialize the CCEAGLView 46 | CCEAGLView *eaglView = [CCEAGLView viewWithFrame: [UIScreen mainScreen].bounds 47 | pixelFormat: (__bridge NSString *)cocos2d::GLViewImpl::_pixelFormat 48 | depthFormat: cocos2d::GLViewImpl::_depthFormat 49 | preserveBackbuffer: NO 50 | sharegroup: nil 51 | multiSampling: NO 52 | numberOfSamples: 0 ]; 53 | 54 | // Enable or disable multiple touches 55 | [eaglView setMultipleTouchEnabled:NO]; 56 | 57 | // Set EAGLView as view of RootViewController 58 | self.view = eaglView; 59 | } 60 | 61 | // Implement viewDidLoad to do additional setup after loading the view, typically from a nib. 62 | - (void)viewDidLoad { 63 | [super viewDidLoad]; 64 | } 65 | 66 | - (void)viewWillAppear:(BOOL)animated { 67 | [super viewWillAppear:animated]; 68 | } 69 | 70 | - (void)viewDidDisappear:(BOOL)animated { 71 | [super viewDidDisappear:animated]; 72 | } 73 | 74 | 75 | // For ios6, use supportedInterfaceOrientations & shouldAutorotate instead 76 | #ifdef __IPHONE_6_0 77 | - (NSUInteger) supportedInterfaceOrientations{ 78 | return UIInterfaceOrientationMaskAllButUpsideDown; 79 | } 80 | #endif 81 | 82 | - (BOOL) shouldAutorotate { 83 | return YES; 84 | } 85 | 86 | - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation { 87 | [super didRotateFromInterfaceOrientation:fromInterfaceOrientation]; 88 | 89 | auto glview = cocos2d::Director::getInstance()->getOpenGLView(); 90 | 91 | if (glview) 92 | { 93 | CCEAGLView *eaglview = (__bridge CCEAGLView *)glview->getEAGLView(); 94 | 95 | if (eaglview) 96 | { 97 | CGSize s = CGSizeMake([eaglview getWidth], [eaglview getHeight]); 98 | cocos2d::Application::getInstance()->applicationScreenSizeChanged((int) s.width, (int) s.height); 99 | } 100 | } 101 | } 102 | 103 | //fix not hide status on ios7 104 | - (BOOL)prefersStatusBarHidden { 105 | return YES; 106 | } 107 | 108 | - (void)didReceiveMemoryWarning { 109 | // Releases the view if it doesn't have a superview. 110 | [super didReceiveMemoryWarning]; 111 | 112 | // Release any cached data, images, etc that aren't in use. 113 | } 114 | 115 | 116 | @end 117 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/ios/main.m: -------------------------------------------------------------------------------- 1 | 2 | 3 | #import 4 | 5 | int main(int argc, char *argv[]) { 6 | @autoreleasepool { 7 | return UIApplicationMain(argc, argv, nil, @"AppController"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/mac/Icon.icns: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.ios_mac/mac/Icon.icns -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/mac/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIconFile 10 | Icon 11 | CFBundleIdentifier 12 | com.test.ios_jsb 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1 25 | LSApplicationCategoryType 26 | public.app-category.games 27 | LSMinimumSystemVersion 28 | ${MACOSX_DEPLOYMENT_TARGET} 29 | NSHumanReadableCopyright 30 | Copyright © 2013. All rights reserved. 31 | NSMainNibFile 32 | MainMenu 33 | NSPrincipalClass 34 | NSApplication 35 | 36 | 37 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/mac/Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header for all source files of the 'Paralaxer' target in the 'Paralaxer' project 3 | // 4 | 5 | #ifdef __OBJC__ 6 | #import 7 | #endif 8 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.ios_mac/mac/main.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | Copyright (c) 2010 cocos2d-x.org 3 | 4 | http://www.cocos2d-x.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | ****************************************************************************/ 24 | 25 | #include "AppDelegate.h" 26 | #include "cocos2d.h" 27 | 28 | USING_NS_CC; 29 | 30 | int main(int argc, char *argv[]) 31 | { 32 | AppDelegate app; 33 | return Application::getInstance()->run(); 34 | } 35 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.linux/main.cpp: -------------------------------------------------------------------------------- 1 | #include "../Classes/AppDelegate.h" 2 | 3 | USING_NS_CC; 4 | 5 | int main(int argc, char **argv) 6 | { 7 | // create the application instance 8 | AppDelegate app; 9 | return Application::getInstance()->run(); 10 | } 11 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/build-cfg.json: -------------------------------------------------------------------------------- 1 | { 2 | "copy_resources": [ 3 | { 4 | "from": "../../../src", 5 | "to": "src" 6 | }, 7 | { 8 | "from": "../../../res", 9 | "to": "res" 10 | }, 11 | { 12 | "from": "../../../main.js", 13 | "to": "" 14 | }, 15 | { 16 | "from": "../../../project.json", 17 | "to": "" 18 | }, 19 | { 20 | "from": "../../cocos2d-x/cocos/scripting/js-bindings/script", 21 | "to": "script" 22 | } 23 | ] 24 | } 25 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/game.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #include "resource.h" 4 | 5 | #define APSTUDIO_READONLY_SYMBOLS 6 | ///////////////////////////////////////////////////////////////////////////// 7 | // 8 | // Generated from the TEXTINCLUDE 2 resource. 9 | // 10 | #include "winresrc.h" 11 | 12 | ///////////////////////////////////////////////////////////////////////////// 13 | #undef APSTUDIO_READONLY_SYMBOLS 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // Chinese (Simplified, PRC) resources 17 | 18 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_CHS) 19 | LANGUAGE LANG_CHINESE, SUBLANG_CHINESE_SIMPLIFIED 20 | #pragma code_page(936) 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 2 TEXTINCLUDE 29 | BEGIN 30 | "#include ""winresrc.h""\r\n" 31 | "\0" 32 | END 33 | 34 | 3 TEXTINCLUDE 35 | BEGIN 36 | "\r\n" 37 | "\0" 38 | END 39 | 40 | #endif // APSTUDIO_INVOKED 41 | 42 | #endif // Chinese (Simplified, PRC) resources 43 | ///////////////////////////////////////////////////////////////////////////// 44 | 45 | 46 | ///////////////////////////////////////////////////////////////////////////// 47 | // English (United States) resources 48 | 49 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 50 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 51 | #pragma code_page(1252) 52 | 53 | #ifdef APSTUDIO_INVOKED 54 | ///////////////////////////////////////////////////////////////////////////// 55 | // 56 | // TEXTINCLUDE 57 | // 58 | 59 | 1 TEXTINCLUDE 60 | BEGIN 61 | "resource.h\0" 62 | END 63 | 64 | #endif // APSTUDIO_INVOKED 65 | 66 | 67 | ///////////////////////////////////////////////////////////////////////////// 68 | // 69 | // Icon 70 | // 71 | 72 | // Icon with lowest ID value placed first to ensure application icon 73 | // remains consistent on all systems. 74 | GLFW_ICON ICON "res\\game.ico" 75 | 76 | ///////////////////////////////////////////////////////////////////////////// 77 | // 78 | // Version 79 | // 80 | 81 | VS_VERSION_INFO VERSIONINFO 82 | FILEVERSION 1,0,0,1 83 | PRODUCTVERSION 1,0,0,1 84 | FILEFLAGSMASK 0x3fL 85 | #ifdef _DEBUG 86 | FILEFLAGS 0x1L 87 | #else 88 | FILEFLAGS 0x0L 89 | #endif 90 | FILEOS 0x4L 91 | FILETYPE 0x2L 92 | FILESUBTYPE 0x0L 93 | BEGIN 94 | BLOCK "StringFileInfo" 95 | BEGIN 96 | BLOCK "040904B0" 97 | BEGIN 98 | VALUE "FileDescription", "game Module" 99 | VALUE "FileVersion", "1, 0, 0, 1" 100 | VALUE "InternalName", "game" 101 | VALUE "LegalCopyright", "Copyright " 102 | VALUE "OriginalFilename", "game.exe" 103 | VALUE "ProductName", "game Module" 104 | VALUE "ProductVersion", "1, 0, 0, 1" 105 | END 106 | END 107 | BLOCK "VarFileInfo" 108 | BEGIN 109 | VALUE "Translation", 0x409, 1200 110 | END 111 | END 112 | 113 | #endif // English (United States) resources 114 | ///////////////////////////////////////////////////////////////////////////// 115 | 116 | 117 | 118 | #ifndef APSTUDIO_INVOKED 119 | ///////////////////////////////////////////////////////////////////////////// 120 | // 121 | // Generated from the TEXTINCLUDE 3 resource. 122 | // 123 | 124 | 125 | ///////////////////////////////////////////////////////////////////////////// 126 | #endif // not APSTUDIO_INVOKED 127 | 128 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/iOS_JSB.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2013 4 | VisualStudioVersion = 12.0.30110.0 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iOS_JSB", "iOS_JSB.vcxproj", "{3B0B58B1-2734-488E-A542-ECEC11EB2455}" 7 | ProjectSection(ProjectDependencies) = postProject 8 | {39379840-825A-45A0-B363-C09FFEF864BD} = {39379840-825A-45A0-B363-C09FFEF864BD} 9 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} = {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E} 10 | EndProjectSection 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "External", "External", "{8C6B0381-B325-4D7F-B1BB-474ABACE46AC}" 13 | EndProject 14 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libSpine", "..\..\cocos2d-x\cocos\editor-support\spine\proj.win32\libSpine.vcxproj", "{B7C2A162-DEC9-4418-972E-240AB3CBFCAE}" 15 | EndProject 16 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libbox2d", "..\..\cocos2d-x\external\Box2D\proj.win32\libbox2d.vcxproj", "{929480E7-23C0-4DF6-8456-096D71547116}" 17 | EndProject 18 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libcocos2d", "..\..\cocos2d-x\cocos\2d\libcocos2d.vcxproj", "{98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}" 19 | EndProject 20 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libjscocos2d", "..\..\cocos2d-x\cocos\scripting\js-bindings\proj.win32\libjscocos2d.vcxproj", "{39379840-825A-45A0-B363-C09FFEF864BD}" 21 | EndProject 22 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "librecast", "..\..\cocos2d-x\external\recast\proj.win32\librecast.vcxproj", "{41E34993-647E-4282-8384-4AB1AE31A452}" 23 | EndProject 24 | Global 25 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 26 | Debug|Win32 = Debug|Win32 27 | Release|Win32 = Release|Win32 28 | EndGlobalSection 29 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 30 | {3B0B58B1-2734-488E-A542-ECEC11EB2455}.Debug|Win32.ActiveCfg = Debug|Win32 31 | {3B0B58B1-2734-488E-A542-ECEC11EB2455}.Debug|Win32.Build.0 = Debug|Win32 32 | {3B0B58B1-2734-488E-A542-ECEC11EB2455}.Release|Win32.ActiveCfg = Release|Win32 33 | {3B0B58B1-2734-488E-A542-ECEC11EB2455}.Release|Win32.Build.0 = Release|Win32 34 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.ActiveCfg = Debug|Win32 35 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Debug|Win32.Build.0 = Debug|Win32 36 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.ActiveCfg = Release|Win32 37 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE}.Release|Win32.Build.0 = Release|Win32 38 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.ActiveCfg = Debug|Win32 39 | {929480E7-23C0-4DF6-8456-096D71547116}.Debug|Win32.Build.0 = Debug|Win32 40 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.ActiveCfg = Release|Win32 41 | {929480E7-23C0-4DF6-8456-096D71547116}.Release|Win32.Build.0 = Release|Win32 42 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.ActiveCfg = Debug|Win32 43 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Debug|Win32.Build.0 = Debug|Win32 44 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.ActiveCfg = Release|Win32 45 | {98A51BA8-FC3A-415B-AC8F-8C7BD464E93E}.Release|Win32.Build.0 = Release|Win32 46 | {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.ActiveCfg = Debug|Win32 47 | {39379840-825A-45A0-B363-C09FFEF864BD}.Debug|Win32.Build.0 = Debug|Win32 48 | {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.ActiveCfg = Release|Win32 49 | {39379840-825A-45A0-B363-C09FFEF864BD}.Release|Win32.Build.0 = Release|Win32 50 | {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.ActiveCfg = Debug|Win32 51 | {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Debug|Win32.Build.0 = Debug|Win32 52 | {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.ActiveCfg = Release|Win32 53 | {012DFF48-A13F-4F52-B07B-F8B9D21CE95B}.Release|Win32.Build.0 = Release|Win32 54 | {41E34993-647E-4282-8384-4AB1AE31A452}.Debug|Win32.ActiveCfg = Debug|Win32 55 | {41E34993-647E-4282-8384-4AB1AE31A452}.Debug|Win32.Build.0 = Debug|Win32 56 | {41E34993-647E-4282-8384-4AB1AE31A452}.Release|Win32.ActiveCfg = Release|Win32 57 | {41E34993-647E-4282-8384-4AB1AE31A452}.Release|Win32.Build.0 = Release|Win32 58 | EndGlobalSection 59 | GlobalSection(SolutionProperties) = preSolution 60 | HideSolutionNode = FALSE 61 | EndGlobalSection 62 | GlobalSection(NestedProjects) = preSolution 63 | {B7C2A162-DEC9-4418-972E-240AB3CBFCAE} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC} 64 | {929480E7-23C0-4DF6-8456-096D71547116} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC} 65 | {012DFF48-A13F-4F52-B07B-F8B9D21CE95B} = {8C6B0381-B325-4D7F-B1BB-474ABACE46AC} 66 | EndGlobalSection 67 | EndGlobal 68 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/iOS_JSB.vcxproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Release 10 | Win32 11 | 12 | 13 | 14 | {3B0B58B1-2734-488E-A542-ECEC11EB2455} 15 | iOS_JSB 16 | 17 | 18 | 19 | Application 20 | Unicode 21 | v120 22 | v120_xp 23 | v140 24 | v140_xp 25 | v141 26 | v141_xp 27 | 28 | 29 | Application 30 | Unicode 31 | v120 32 | v120_xp 33 | v140 34 | v140_xp 35 | v141 36 | v141_xp 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | <_ProjectFileVersion>12.0.21005.1 54 | $(SolutionDir)$(Configuration).win32\ 55 | $(Configuration).win32\ 56 | false 57 | $(SolutionDir)$(Configuration).win32\ 58 | $(Configuration).win32\ 59 | false 60 | AllRules.ruleset 61 | 62 | 63 | AllRules.ruleset 64 | 65 | 66 | 67 | 68 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) 69 | 70 | 71 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\lib;$(LibraryPath) 72 | 73 | 74 | 75 | _DEBUG;%(PreprocessorDefinitions) 76 | false 77 | Win32 78 | true 79 | $(IntDir)game.tlb 80 | game.h 81 | 82 | 83 | game_i.c 84 | game_p.c 85 | 86 | 87 | Disabled 88 | $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) 89 | WIN32;_WINDOWS;STRICT;_DEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_DEBUG=1;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 90 | false 91 | EnableFastChecks 92 | MultiThreadedDebugDLL 93 | 94 | 95 | Level3 96 | EditAndContinue 97 | 4267;4251;4244;4800;%(DisableSpecificWarnings) 98 | true 99 | 100 | 101 | _DEBUG;%(PreprocessorDefinitions) 102 | 0x0409 103 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) 104 | 105 | 106 | 107 | 108 | 109 | mozjs-33.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) 110 | $(OutDir);%(AdditionalLibraryDirectories) 111 | true 112 | Windows 113 | MachineX86 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\js-bindings\script" "$(OutDir)\script" /D /E /I /F /Y 125 | xcopy "$(ProjectDir)..\..\..\src" "$(OutDir)\src" /D /E /I /F /Y 126 | xcopy "$(ProjectDir)..\..\..\res" "$(OutDir)\res" /D /E /I /F /Y 127 | copy "$(ProjectDir)..\..\..\main.js" "$(OutDir)\" /Y 128 | copy "$(ProjectDir)..\..\..\project.json" "$(OutDir)\" /Y 129 | $(TargetName).cab 130 | $(TargetFileName) 131 | 132 | 133 | 134 | 135 | NDEBUG;%(PreprocessorDefinitions) 136 | false 137 | Win32 138 | true 139 | $(IntDir)game.tlb 140 | game.h 141 | 142 | 143 | game_i.c 144 | game_p.c 145 | 146 | 147 | $(ProjectDir)..\Classes;$(EngineRoot);$(EngineRoot)cocos;$(EngineRoot)external\spidermonkey\include\win32;$(EngineRoot)external\chipmunk\include\chipmunk;$(EngineRoot)extensions;%(AdditionalIncludeDirectories) 148 | WIN32;_WINDOWS;STRICT;NDEBUG;XP_WIN;JS_HAVE___INTN;JS_INTPTR_TYPE=int;COCOS2D_JAVASCRIPT=1;CC_ENABLE_CHIPMUNK_INTEGRATION=1;_CRT_SECURE_NO_WARNINGS;_SCL_SECURE_NO_WARNINGS;_USRJSSTATIC;_USRLIBSIMSTATIC;%(PreprocessorDefinitions) 149 | 150 | 151 | MultiThreadedDLL 152 | 153 | 154 | Level3 155 | 156 | 157 | 4267;4251;4244;4800;%(DisableSpecificWarnings) 158 | true 159 | 160 | 161 | NDEBUG;%(PreprocessorDefinitions) 162 | 0x0409 163 | $(MSBuildProgramFiles32)\Microsoft SDKs\Windows\v7.1A\include;$(IntDir);%(AdditionalIncludeDirectories) 164 | 165 | 166 | 167 | 168 | 169 | mozjs-33.lib;ws2_32.lib;sqlite3.lib;%(AdditionalDependencies) 170 | $(OutDir);%(AdditionalLibraryDirectories) 171 | Windows 172 | MachineX86 173 | true 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | {39379840-825a-45a0-b363-c09ffef864bd} 197 | 198 | 199 | 200 | 201 | 202 | 203 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/iOS_JSB.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {ca9c9e15-d942-43a1-aa7a-5f0b74ca1afd} 6 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;jpg;jpeg;jpe;png;manifest 7 | 8 | 9 | {ccb2323b-1cfa-41ea-bcf4-ba5f07309396} 10 | 11 | 12 | {e93a77e1-af1e-4400-87d3-504b62ebdbb0} 13 | 14 | 15 | 16 | 17 | win32 18 | 19 | 20 | Classes 21 | 22 | 23 | 24 | 25 | Classes 26 | 27 | 28 | win32 29 | 30 | 31 | 32 | 33 | 34 | resource 35 | 36 | 37 | 38 | 39 | resource 40 | 41 | 42 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/iOS_JSB.vcxproj.user: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | $(OutDir) 5 | WindowsLocalDebugger 6 | 7 | 8 | $(OutDir) 9 | WindowsLocalDebugger 10 | 11 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/main.cpp: -------------------------------------------------------------------------------- 1 | #include "main.h" 2 | #include "AppDelegate.h" 3 | 4 | USING_NS_CC; 5 | 6 | // uncomment below line, open debug console 7 | // #define USE_WIN32_CONSOLE 8 | 9 | int WINAPI _tWinMain(HINSTANCE hInstance, 10 | HINSTANCE hPrevInstance, 11 | LPTSTR lpCmdLine, 12 | int nCmdShow) 13 | { 14 | UNREFERENCED_PARAMETER(hPrevInstance); 15 | UNREFERENCED_PARAMETER(lpCmdLine); 16 | 17 | #ifdef USE_WIN32_CONSOLE 18 | AllocConsole(); 19 | freopen("CONIN$", "r", stdin); 20 | freopen("CONOUT$", "w", stdout); 21 | freopen("CONOUT$", "w", stderr); 22 | #endif 23 | 24 | // create the application instance 25 | AppDelegate app; 26 | int ret = Application::getInstance()->run(); 27 | 28 | #ifdef USE_WIN32_CONSOLE 29 | FreeConsole(); 30 | #endif 31 | 32 | return ret; 33 | } 34 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/main.h: -------------------------------------------------------------------------------- 1 | #ifndef __MAIN_H__ 2 | #define __MAIN_H__ 3 | 4 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers 5 | 6 | // Windows Header Files: 7 | #include 8 | 9 | // C RunTime Header Files 10 | #include "platform/CCStdC.h" 11 | 12 | #endif // __WINMAIN_H__ 13 | -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/res/game.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/frameworks/runtime-src/proj.win32/res/game.ico -------------------------------------------------------------------------------- /frameworks/runtime-src/proj.win32/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by game.rc 4 | // 5 | #define IDS_PROJNAME 100 6 | #define IDR_TESTJS 100 7 | 8 | // Next default values for new objects 9 | // 10 | #ifdef APSTUDIO_INVOKED 11 | #ifndef APSTUDIO_READONLY_SYMBOLS 12 | #define _APS_NEXT_RESOURCE_VALUE 204 13 | #define _APS_NEXT_COMMAND_VALUE 32785 14 | #define _APS_NEXT_CONTROL_VALUE 1001 15 | #define _APS_NEXT_SYMED_VALUE 101 16 | #endif 17 | #endif 18 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Cocos2d-html5 Hello World test 6 | 7 | 8 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | -------------------------------------------------------------------------------- /main.js: -------------------------------------------------------------------------------- 1 | /** 2 | * A brief explanation for "project.json": 3 | * Here is the content of project.json file, this is the global configuration for your game, you can modify it to customize some behavior. 4 | * The detail of each field is under it. 5 | { 6 | "project_type": "javascript", 7 | // "project_type" indicate the program language of your project, you can ignore this field 8 | 9 | "debugMode" : 1, 10 | // "debugMode" possible values : 11 | // 0 - No message will be printed. 12 | // 1 - cc.error, cc.assert, cc.warn, cc.log will print in console. 13 | // 2 - cc.error, cc.assert, cc.warn will print in console. 14 | // 3 - cc.error, cc.assert will print in console. 15 | // 4 - cc.error, cc.assert, cc.warn, cc.log will print on canvas, available only on web. 16 | // 5 - cc.error, cc.assert, cc.warn will print on canvas, available only on web. 17 | // 6 - cc.error, cc.assert will print on canvas, available only on web. 18 | 19 | "showFPS" : true, 20 | // Left bottom corner fps information will show when "showFPS" equals true, otherwise it will be hide. 21 | 22 | "frameRate" : 60, 23 | // "frameRate" set the wanted frame rate for your game, but the real fps depends on your game implementation and the running environment. 24 | 25 | "noCache" : false, 26 | // "noCache" set whether your resources will be loaded with a timestamp suffix in the url. 27 | // In this way, your resources will be force updated even if the browser holds a cache of it. 28 | // It's very useful for mobile browser debugging. 29 | 30 | "id" : "gameCanvas", 31 | // "gameCanvas" sets the id of your canvas element on the web page, it's useful only on web. 32 | 33 | "renderMode" : 0, 34 | // "renderMode" sets the renderer type, only useful on web : 35 | // 0 - Automatically chosen by engine 36 | // 1 - Forced to use canvas renderer 37 | // 2 - Forced to use WebGL renderer, but this will be ignored on mobile browsers 38 | 39 | "engineDir" : "frameworks/cocos2d-html5/", 40 | // In debug mode, if you use the whole engine to develop your game, you should specify its relative path with "engineDir", 41 | // but if you are using a single engine file, you can ignore it. 42 | 43 | "modules" : ["cocos2d"], 44 | // "modules" defines which modules you will need in your game, it's useful only on web, 45 | // using this can greatly reduce your game's resource size, and the cocos console tool can package your game with only the modules you set. 46 | // For details about modules definitions, you can refer to "../../frameworks/cocos2d-html5/modulesConfig.json". 47 | 48 | "jsList" : [ 49 | ] 50 | // "jsList" sets the list of js files in your game. 51 | } 52 | * 53 | */ 54 | 55 | cc.game.onStart = function(){ 56 | var sys = cc.sys; 57 | if(!sys.isNative && document.getElementById("cocosLoading")) //If referenced loading.js, please remove it 58 | document.body.removeChild(document.getElementById("cocosLoading")); 59 | 60 | // Pass true to enable retina display, on Android disabled by default to improve performance 61 | cc.view.enableRetina(sys.os === sys.OS_IOS ? true : false); 62 | 63 | // Disable auto full screen on baidu and wechat, you might also want to eliminate sys.BROWSER_TYPE_MOBILE_QQ 64 | if (sys.isMobile && 65 | sys.browserType !== sys.BROWSER_TYPE_BAIDU && 66 | sys.browserType !== sys.BROWSER_TYPE_WECHAT) { 67 | cc.view.enableAutoFullScreen(true); 68 | } 69 | 70 | // Adjust viewport meta 71 | cc.view.adjustViewPort(true); 72 | 73 | // Uncomment the following line to set a fixed orientation for your game 74 | // cc.view.setOrientation(cc.ORIENTATION_PORTRAIT); 75 | 76 | // Setup the resolution policy and design resolution size 77 | cc.view.setDesignResolutionSize(960, 640, cc.ResolutionPolicy.SHOW_ALL); 78 | 79 | // The game will be resized when browser size change 80 | cc.view.resizeWithBrowserSize(true); 81 | 82 | //load resources 83 | cc.LoaderScene.preload(g_resources, function () { 84 | cc.director.runScene(new HelloWorldScene()); 85 | }, this); 86 | }; 87 | cc.game.run(); -------------------------------------------------------------------------------- /manifest.webapp: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0", 3 | "name": "iOS_JSB", 4 | "description": "iOS_JSB", 5 | "launch_path": "/index.html", 6 | "icons": { 7 | "128": "/res/icon.png" 8 | }, 9 | "developer": { 10 | "name": "Cocos2d-html5", 11 | "url": "http://cocos2d-x.org/" 12 | }, 13 | "default_locale": "en", 14 | "installs_allowed_from": [ 15 | "*" 16 | ], 17 | "orientation": "portrait-primary", 18 | "fullscreen": "true" 19 | } 20 | -------------------------------------------------------------------------------- /project.json: -------------------------------------------------------------------------------- 1 | { 2 | "project_type": "javascript", 3 | 4 | "debugMode" : 1, 5 | "showFPS" : true, 6 | "frameRate" : 24, 7 | "noCache" : false, 8 | "id" : "gameCanvas", 9 | "renderMode" : 0, 10 | "engineDir":"frameworks/cocos2d-html5", 11 | 12 | "modules" : ["cocos2d"], 13 | 14 | "jsList" : [ 15 | "src/resource.js", 16 | "src/app.js" 17 | ] 18 | } 19 | -------------------------------------------------------------------------------- /res/HelloWorld.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/BB9z/Cocos2d-js-binding-demo/c47721a69fcd22a3a6f07d3789dda26e4c3d5712/res/HelloWorld.png -------------------------------------------------------------------------------- /res/loading.js: -------------------------------------------------------------------------------- 1 | (function(){var createStyle=function(){return".cocosLoading{position:absolute;margin:-30px -60px;padding:0;top:50%;left:50%}"+".cocosLoading ul{margin:0;padding:0;}"+".cocosLoading span{color:#FFF;text-align:center;display:block;}"+".cocosLoading li{list-style:none;float:left;border-radius:15px;width:15px;height:15px;background:#FFF;margin:5px 0 0 10px}"+".cocosLoading li .ball,.cocosLoading li .unball{background-color:#2187e7;background-image:-moz-linear-gradient(90deg,#2187e7 25%,#a0eaff);background-image:-webkit-linear-gradient(90deg,#2187e7 25%,#a0eaff);width:15px;height:15px;border-radius:50px}"+".cocosLoading li .ball{transform:scale(0);-moz-transform:scale(0);-webkit-transform:scale(0);animation:showDot 1s linear forwards;-moz-animation:showDot 1s linear forwards;-webkit-animation:showDot 1s linear forwards}"+".cocosLoading li .unball{transform:scale(1);-moz-transform:scale(1);-webkit-transform:scale(1);animation:hideDot 1s linear forwards;-moz-animation:hideDot 1s linear forwards;-webkit-animation:hideDot 1s linear forwards}"+"@keyframes showDot{0%{transform:scale(0,0)}100%{transform:scale(1,1)}}"+"@-moz-keyframes showDot{0%{-moz-transform:scale(0,0)}100%{-moz-transform:scale(1,1)}}"+"@-webkit-keyframes showDot{0%{-webkit-transform:scale(0,0)}100%{-webkit-transform:scale(1,1)}}"+"@keyframes hideDot{0%{transform:scale(1,1)}100%{transform:scale(0,0)}}"+"@-moz-keyframes hideDot{0%{-moz-transform:scale(1,1)}100%{-moz-transform:scale(0,0)}}"+"@-webkit-keyframes hideDot{0%{-webkit-transform:scale(1,1)}100%{-webkit-transform:scale(0,0)}}"};var createDom=function(id,num){id=id||"cocosLoading";num=num||5;var i,item;var div=document.createElement("div");div.className="cocosLoading";div.id=id;var bar=document.createElement("ul");var list=[];for(i=0;i=list.length){direction=!direction;index=0;time=1000}else{time=300}animation()},time)};animation()};(function(){var bgColor=document.body.style.background;document.body.style.background="#000";var style=document.createElement("style");style.type="text/css";style.innerHTML=createStyle();document.head.appendChild(style);var list=createDom();startAnimation(list,function(){var div=document.getElementById("cocosLoading");if(!div){document.body.style.background=bgColor}return !!div})})()})(); -------------------------------------------------------------------------------- /src/app.js: -------------------------------------------------------------------------------- 1 | 2 | 3 | // 还是为了简便,把所有 demo 都写在这了,也只演示 iOS 的 4 | if (sys.os === sys.OS_IOS) { 5 | var log = console.log; 6 | log('\nJSB demo start 🔜\n'); 7 | 8 | // 调用 native 静态方法 9 | var ret = jsb.reflection.callStaticMethod('AppController', 'demoReverseListString:', 'foo,bar,apple,tree'); 10 | log('🔶 jsb.reflection return: ' + ret); 11 | 12 | // 演示 native 通过 ScriptingCore 调用 JS 13 | // 代码在 native 项目中,这里只触发 14 | jsb.reflection.callStaticMethod('AppController', 'demoScriptingCore'); 15 | 16 | // 调用 JSB 注入的方法 17 | log('🔶 iOS.APIVersion: ' + iOS.APIVersion); 18 | log('🔶 1 + 1 = ' + iOS.demoAdd(1, 1)); 19 | iOS.demoAsyncOperation('x', deomCallbackHandler); 20 | iOS.demoAsyncOperation('this will success', function(response, error) { 21 | log('🔶 native response: ' + response); 22 | log('\nJSB demo end 🔚\n'); 23 | }); 24 | 25 | log('JSB demo EOF'); 26 | } 27 | 28 | function deomCallbackHandler (response, error) { 29 | if (error) { 30 | if (error.code === 'TEST') { 31 | console.log('🔶 operation failed with error: TEST'); 32 | return; 33 | } 34 | throw error; 35 | } 36 | console.log('🔶 operation succeed with response: ' + response); 37 | } 38 | 39 | 40 | var HelloWorldLayer = cc.Layer.extend({ 41 | sprite:null, 42 | ctor:function () { 43 | ////////////////////////////// 44 | // 1. super init first 45 | this._super(); 46 | 47 | ///////////////////////////// 48 | // 2. add a menu item with "X" image, which is clicked to quit the program 49 | // you may modify it. 50 | // ask the window size 51 | var size = cc.winSize; 52 | 53 | ///////////////////////////// 54 | // 3. add your codes below... 55 | // add a label shows "Hello World" 56 | // create and initialize a label 57 | var helloLabel = new cc.LabelTTF("Hello World", "Arial", 38); 58 | // position the label on the center of the screen 59 | helloLabel.x = size.width / 2; 60 | helloLabel.y = size.height / 2 + 200; 61 | // add the label as a child to this layer 62 | this.addChild(helloLabel, 5); 63 | 64 | // add "HelloWorld" splash screen" 65 | this.sprite = new cc.Sprite(res.HelloWorld_png); 66 | this.sprite.attr({ 67 | x: size.width / 2, 68 | y: size.height / 2 69 | }); 70 | this.addChild(this.sprite, 0); 71 | 72 | return true; 73 | } 74 | }); 75 | 76 | var HelloWorldScene = cc.Scene.extend({ 77 | onEnter:function () { 78 | this._super(); 79 | var layer = new HelloWorldLayer(); 80 | this.addChild(layer); 81 | } 82 | }); 83 | 84 | -------------------------------------------------------------------------------- /src/resource.js: -------------------------------------------------------------------------------- 1 | var res = { 2 | HelloWorld_png : "res/HelloWorld.png", 3 | }; 4 | 5 | var g_resources = []; 6 | for (var i in res) { 7 | g_resources.push(res[i]); 8 | } 9 | --------------------------------------------------------------------------------