Merge pull request #1401 from cocos-creator/next

sync branch
This commit is contained in:
Jare Guo
2018-07-19 13:51:40 +08:00
committed by GitHub
7 changed files with 69 additions and 36 deletions
@@ -104,6 +104,8 @@ namespace
}
}
void cocos_jni_env_init (JNIEnv* env);
Application* cocos_android_app_init(JNIEnv* env, int width, int height);
extern "C"
@@ -111,6 +113,7 @@ extern "C"
JNIEXPORT jint JNI_OnLoad(JavaVM *vm, void *reserved)
{
JniHelper::setJavaVM(vm);
cocos_jni_env_init(JniHelper::getEnv());
return JNI_VERSION_1_4;
}
@@ -34,6 +34,13 @@
#include "cocos/scripting/js-bindings/event/CustomEventTypes.h"
#include "cocos/scripting/js-bindings/manual/jsb_classtype.hpp"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
#include "SDKManager.h"
#include "jsb_anysdk_protocols_auto.hpp"
#include "manualanysdkbindings.hpp"
using namespace anysdk::framework;
#endif
USING_NS_CC;
AppDelegate::AppDelegate(int width, int height) : Application("Cocos Game", width, height)
@@ -42,11 +49,17 @@ AppDelegate::AppDelegate(int width, int height) : Application("Cocos Game", widt
AppDelegate::~AppDelegate()
{
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
SDKManager::getInstance()->purge();
#endif
}
bool AppDelegate::applicationDidFinishLaunching()
{
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS && PACKAGE_AS
SDKManager::getInstance()->loadAllPlugins();
#endif
se::ScriptEngine* se = se::ScriptEngine::getInstance();
jsb_set_xxtea_key("");
@@ -64,6 +77,11 @@ bool AppDelegate::applicationDidFinishLaunching()
jsb_register_all_modules();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
se->addRegisterCallback(register_all_anysdk_framework);
se->addRegisterCallback(register_all_anysdk_manual);
#endif
se->start();
se::AutoHandleScope hs;
@@ -34,7 +34,7 @@ class AppDelegate : public cocos2d::Application
{
public:
AppDelegate(int width, int height);
~AppDelegate();
virtual ~AppDelegate();
/**
@brief Implement Director and Scene init code here.
@@ -7,7 +7,7 @@ android {
buildToolsVersion PROP_BUILD_TOOLS_VERSION
defaultConfig {
applicationId "org.cocos2d.helloworld"
applicationId "org.cocos2dx.hellojavascript"
minSdkVersion PROP_MIN_SDK_VERSION
targetSdkVersion PROP_TARGET_SDK_VERSION
versionCode 1
@@ -41,23 +41,29 @@ using namespace cocos2d;
using namespace anysdk::framework;
#endif
Application* cocos_android_app_init (JNIEnv* env, int width, int height) {
LOGD("cocos_android_app_init");
auto app = new AppDelegate(width, height);
//called when JNI_OnLoad()
void cocos_jni_env_init (JNIEnv* env) {
LOGD("cocos_jni_env_init");
#if PACKAGE_AS
JavaVM* vm;
JavaVM *vm;
env->GetJavaVM(&vm);
PluginJniHelper::setJavaVM(vm);
#endif
}
//called when onSurfaceCreated()
Application* cocos_android_app_init (JNIEnv* env, int width, int height) {
LOGD("cocos_android_app_init");
auto app = new AppDelegate(width, height);
return app;
}
extern "C"
{
void Java_org_cocos2dx_javascript_SDKWrapper_nativeLoadAllPlugins(JNIEnv* env, jobject thiz)
{
void Java_org_cocos2dx_javascript_SDKWrapper_nativeLoadAllPlugins(JNIEnv* env, jobject thiz)
{
#if PACKAGE_AS
SDKManager::getInstance()->loadAllPlugins();
SDKManager::getInstance()->loadAllPlugins();
#endif
}
}
}
@@ -34,12 +34,12 @@
#include "cocos/scripting/js-bindings/event/CustomEventTypes.h"
#include "cocos/scripting/js-bindings/manual/jsb_classtype.hpp"
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
//#include "SDKManager.h"
//#include "jsb_anysdk_protocols_auto.hpp"
//#include "manualanysdkbindings.hpp"
//using namespace anysdk::framework;
//#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
#include "SDKManager.h"
#include "jsb_anysdk_protocols_auto.hpp"
#include "manualanysdkbindings.hpp"
using namespace anysdk::framework;
#endif
USING_NS_CC;
@@ -49,16 +49,16 @@ AppDelegate::AppDelegate(int width, int height) : Application("Cocos Game", widt
AppDelegate::~AppDelegate()
{
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
// SDKManager::getInstance()->purge();
//#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
SDKManager::getInstance()->purge();
#endif
}
bool AppDelegate::applicationDidFinishLaunching()
{
//#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS && PACKAGE_AS
// SDKManager::getInstance()->loadAllPlugins();
//#endif
#if CC_TARGET_PLATFORM == CC_PLATFORM_IOS && PACKAGE_AS
SDKManager::getInstance()->loadAllPlugins();
#endif
se::ScriptEngine* se = se::ScriptEngine::getInstance();
@@ -77,12 +77,12 @@ bool AppDelegate::applicationDidFinishLaunching()
jsb_register_all_modules();
se->start();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
se->addRegisterCallback(register_all_anysdk_framework);
se->addRegisterCallback(register_all_anysdk_manual);
#endif
//#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID || CC_TARGET_PLATFORM == CC_PLATFORM_IOS) && PACKAGE_AS
// se->addRegisterCallback(register_all_anysdk_framework);
// se->addRegisterCallback(register_all_anysdk_manual);
//#endif
se->start();
se::AutoHandleScope hs;
jsb_run_script("jsb-adapter/jsb-builtin.js");
@@ -41,23 +41,29 @@ using namespace cocos2d;
using namespace anysdk::framework;
#endif
Application* cocos_android_app_init (JNIEnv* env, int width, int height) {
LOGD("cocos_android_app_init");
auto app = new AppDelegate(width, height);
//called when JNI_OnLoad()
void cocos_jni_env_init (JNIEnv* env) {
LOGD("cocos_jni_env_init");
#if PACKAGE_AS
JavaVM* vm;
JavaVM *vm;
env->GetJavaVM(&vm);
PluginJniHelper::setJavaVM(vm);
#endif
}
//called when onSurfaceCreated()
Application* cocos_android_app_init (JNIEnv* env, int width, int height) {
LOGD("cocos_android_app_init");
auto app = new AppDelegate(width, height);
return app;
}
extern "C"
{
void Java_org_cocos2dx_javascript_SDKWrapper_nativeLoadAllPlugins(JNIEnv* env, jobject thiz)
{
void Java_org_cocos2dx_javascript_SDKWrapper_nativeLoadAllPlugins(JNIEnv* env, jobject thiz)
{
#if PACKAGE_AS
SDKManager::getInstance()->loadAllPlugins();
SDKManager::getInstance()->loadAllPlugins();
#endif
}
}
}