I have added screenshots of resources folder of my project and logcat shown in my eclipse.
it needs to be in res
Have moved sdkbox_config.json to res folder. Built the project again.Still getting the same error.
ok, one other thing, can you show my the contents of your Cocos2dxActivity.java
I have edited the Cocos2dxActivity.java file located at following location.
…\cocos2d\cocos\platform\android\java\src\org\cocos2dx\lib
Have also attached my Android.mk file. Kindly look into it and if possible make corrections in the file and send it back.
Files.zip (4.2 KB)
Thanks for the updated document. I was able to find the issue. My project.properties file did not have this reference.
“android.library.reference.1=…/…/cocos2d-x/cocos/platform/android/java”
This reference is removed when I imported my project to eclipse and added libcocos2dx as library file to my project.
I tried building the project without importing to eclipse and now it reades cocos2dxActivity.java but get the following error:
package org.cocos2dx.plugin does not exist.
Can you tell me how to add this plugin.
So, I would
-
make sure you have all the
.jars
fromplugin/android/libs
copied into the correct location -
make sure you have all the
jni
dir also fromplugin/android/jni
toproj.android/jni/
-
Make sure your Cocos2dxActivity has these pieces in it.
- Modify
Cocos2dxActivity.java
to add the following imports:
import android.content.Intent;
import org.cocos2dx.plugin.PluginWrapper;
- Second, modify
Cocos2dxActivity
to edit theonCreate(final Bundle savedInstanceState)
function to add a call toPluginWrapper.init(this);
. The placement of this call is important. It must be done after the call toonLoadNativeLibraries();
. Example:
onLoadNativeLibraries();
PluginWrapper.init(this);
- Last, we need to insert the proper overrides code. There are a few rules here.
-
If the method listed has not been defined, add it.
-
If the method listed has been defined, add the calls to
PluginWrapper
in the same existing function.
-
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
if(!PluginWrapper.onActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
}
}
@Override
protected void onStart() {
super.onStart();
PluginWrapper.onStart();
}
@Override
protected void onStop() {
super.onStop();
PluginWrapper.onStop();
}
@Override
protected void onResume() {
super.onResume();
PluginWrapper.onResume();
}
@Override
protected void onPause() {
super.onPause();
PluginWrapper.onPause();
}
@Override
public void onBackPressed() {
if(!PluginWrapper.onBackPressed()) {
super.onBackPressed();
}
}
Hi I have same issue
cocos2d-x-3.6 + sdkbox-iap_cpp_v1.1.4
I tested with pathes assets/sdkbox_config.json, assets/res/sdkbox_config.json, assets/[some folder registered to search path]/sdkbox_config.json
but everything are failed to find this file
I could know the file existance clearly with using “FileUtils::getInstance()->fullPathForFilename(“sdkbox_config.json”).c_str());” in jni code debugging
could you let me know which folders are searched when “sdkbox::IAP::init();” is called?
Make sure the json file is added to the project.
Can you also double check you change the Cocos2dxActivity.java
file?
When i checked PluginWrapper code there are no onStart … functions so i excepted these
and i try to find PluginWrapper’s onStart in cocos2d-x 3.6 plugin folder but i can’t find it
what’s wrong?
I generated plugin from source code build script
I am using libPluginProtocol.jar it has PluginWrapper and sdkbox.jar also has same class
the “Multiple dex files define Lorg/cocos2dx/plugin/IAPWrapper” error was occurred
I think every user using plugin-x could have this issue
Could you guide me for this case?
We’re trying to fix this issue. The fix should be in the next release
We fixed this in our 1.1.5 release
Please download the latest version here.
http://cocos2d-x.org/sdkbox
Thanks to your effort It is done well with 1.1.5 version
I let PluginWrapper code be already implemented and added SdkBox functions part
It works well
That’s great~
Hi, i having this error.
I did the sdkbox installation with no erros.
I did the facebook plugin installation and a i got
C:\zcosas\cocos2d\TilesV3a>sdkbox
_______ ______ _ _ ______ _____ _ _
|______ | \ |____/ |_____] | |___/
______| |_____/ | \_ |_____] |_____| _/ \_
Copyright (c) 2015 SDKBOX Inc. v1.0.0.9
usage: sdkbox [-h] [-v] [-p [PROJECT]] [-b [PLUGIN]] [-D SYMBOL] [-q]
[-d [DAYS]] [--china] [--dryrun] [--forcedownload] [--noupdate]
[--alwaysupdate] [--patcherrors] [--nopatching]
[--nopatchingcpp] [--jsonapi] [--forcecopy] [--mkey MKEY]
[--mvalue MVALUE] [--local] [--remote] [--info INFO]
{import,info,update,forget,restore,list,clean,symbols,version,set,
tracking}
sdkbox: error: too few arguments
C:\zcosas\cocos2d\TilesV3a>sdkbox import facebook
_______ ______ _ _ ______ _____ _ _
|______ | \ |____/ |_____] | | \___/
______| |_____/ | \_ |_____] |_____| _/ \_
Copyright (c) 2015 SDKBOX Inc. v1.0.0.9
failed to patch file AppDelegate.cpp
Please reference the online documentation to finish the integration:
http://sdkbox-doc.github.io/en/plugins/facebook/v3-js/
Some installation steps failed.
Please refer to the online documentation, for instructions on how to complete t
he installation manually.
Installation completed with errors :|
C:\zcosas\cocos2d\TilesV3a>sdkbox symbols
_______ ______ _ _ ______ _____ _ _
|______ | \ |____/ |_____] | | \___/
______| |_____/ | \_ |_____] |_____| _/ \_
Copyright (c) 2015 SDKBOX Inc. v1.0.0.9
SDKBOX installer script symbols:
ANDROID_ACTIVITY_NAME AppActivity
ANDROID_ACTIVITY_PATH C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/src/org/cocos2dx/javascript/
ANDROID_COCOS_PACKAGE_ROOT C:/zcosas/cocos2d/TilesV3a/frameworks/js
-bindings/cocos2d-x/cocos/platform/android/java/
ANDROID_COCOS_SRC_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/js
-bindings/cocos2d-x/cocos/platform/android/java/src/org/cocos2dx/lib/
ANDROID_JNI_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/jni/
ANDROID_LIBS_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/js
-bindings/cocos2d-x/cocos/platform/android/java/libs/
ANDROID_MANIFEST C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/AndroidManifest.xml
ANDROID_MK C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/jni/Android.mk
ANDROID_MK_USES_WILDCARDS False
ANDROID_PROJECT_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/
ANDROID_PROPERTIES C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/project.properties
ANDROID_SDK_DIR c:/users/oscar/appdata/local/android/sdk
/
ANDROID_STUDIO_ACTIVITY_NAME n/a
ANDROID_STUDIO_ACTIVITY_PATH n/a
ANDROID_STUDIO_JNI_DIR n/a
ANDROID_STUDIO_LIBS_DIR n/a
ANDROID_STUDIO_MANIFEST n/a
ANDROID_STUDIO_MK n/a
ANDROID_STUDIO_PROJECT_DIR n/a
ANDROID_STUDIO_PROPERTIES n/a
APPLICATION_MK C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.android/jni/Application.mk
COCOS_2DX_INSTALLATION_VERSION 3.5.0
COCOS_2DX_ROOT C:/zcosas/android-soft/cocos2d-js-v3.5/c
ocos2d-js-v3.5/
COCOS_2DX_VERSION 3.5.0
COCOS_BACKUP_DIR C:/zcosas/cocos2d/TilesV3a/backup-2016-0
3-29/
COCOS_CLASSES_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/Classes/
COCOS_ENGINE_TYPE unknown
COCOS_PROJECT_DIR C:/zcosas/cocos2d/TilesV3a/
COCOS_PROJECT_HINT C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/
COCOS_PROJECT_TYPE js
COCOS_RESOURCES_DIR C:/zcosas/cocos2d/TilesV3a/res/
IOS_PROJECT_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.ios_mac/
SDKBOX_DIR C:/Users/oscar/.sdkbox/
XCODE_PROJECT C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.ios_mac/project.pbxproj
XCODE_PROJECT_DIR C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/proj.ios_mac/
C:\zcosas\cocos2d\TilesV3a>sdkbox -vv import facebook
_______ ______ _ _ ______ _____ _ _
|______ | \ |____/ |_____] | | \___/
______| |_____/ | \_ |_____] |_____| _/ \_
Copyright (c) 2015 SDKBOX Inc. v1.0.0.9
Namespace(alwaysupdate=0, china=0, command='import', days=10, dryrun=None, forc
ecopy=0, forcedownload=0, info=None, installer='C:/zcosas/android-soft/sdkbox_in
staller/sdkbox.pyc', jsonapi=0, local=0, manifest='manifest.json', mkey=None, mv
alue=None, nohelp=0, nopatching=0, nopatchingcpp=0, noupdate=0, patcherrors=0, p
lugin='facebook/', project='C:/zcosas/cocos2d/TilesV3a/', remote=0, server='down
load.sdkbox.com/installer/v1/', symbol=None, verbose=2)
cache time out: 24
get cache data len: 22638
share playphone scientificrevenue leadbolt valuepotion chartboost kochava googl
eanalytics soomlagrow review googleplayservices anysdk fyber tune agecheq iap le
aderboard sdkboxads amazon flurryanalytics inmobi vungle SDKBOX achievement yout
ube admob appodeal bee7 facebook adcolony
cocos2d-x installation directory C:/zcosas/android-soft/cocos2d-js-v3.5/cocos2d
-js-v3.5/
cocos2d-x header directory C:/zcosas/android-soft/cocos2d-js-v3.5/cocos2d-js-v3
.5/frameworks/js-bindings/cocos2d-x/cocos/
cocos2d-x installation version 3.5.0
looking for cocos2d.h at C:/zcosas/cocos2d/TilesV3a/frameworks/js-bindings/coco
s2d-x/cocos
cocos2d-x project root C:/zcosas/cocos2d/TilesV3a/
fallback to cocos project search False
cocos2d-x project type js
loaded package manifest
loaded cocos project
iOS project dirs ['C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.ios_m
ac']
failed to load xcode project
loaded android project
failed to load android studio project
supported projects cocos android
package base name facebook
skipping download of sdkbox-facebook_v2.1.2.7.tar.gz, already exists as C:/User
s/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/
setting plugin source to C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.
7/
SHA1 of downloaded package d25ff5921a36536d71159239d38892566fdd4835
plugin exist setting --nopatching
adding to backup .sdkbox_packages.json.xCmh0HWf.sdkbox.temp as C:/zcosas/cocos2
d/TilesV3a/.sdkbox_packages.json
adding to backup Android.mk.Kh0Zyqgv.sdkbox.temp as C:/zcosas/cocos2d/TilesV3a/
frameworks/runtime-src/proj.android/jni/Android.mk
adding to backup Application.mk.COg0NxP5.sdkbox.temp as C:/zcosas/cocos2d/Tiles
V3a/frameworks/runtime-src/proj.android/jni/Application.mk
adding to backup AndroidManifest.xml.jWtvlSzC.sdkbox.temp as C:/zcosas/cocos2d/
TilesV3a/frameworks/runtime-src/proj.android/AndroidManifest.xml
adding to backup project.properties.iRctAZf6.sdkbox.temp as C:/zcosas/cocos2d/T
ilesV3a/frameworks/runtime-src/proj.android/project.properties
found sdkbox.package at C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7
/plugin/sdkbox.package
defining constant SDKBOX_PLUGIN_NAME=>Facebook
Saving to C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.android/projec
t.properties from project.properties.iRctAZf6.sdkbox.temp
Saving to C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.android/Androi
dManifest.xml from AndroidManifest.xml.jWtvlSzC.sdkbox.temp
Saving to C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.android/jni/An
droid.mk from Android.mk.Kh0Zyqgv.sdkbox.temp
Saving to C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.android/jni/Ap
plication.mk from Application.mk.COg0NxP5.sdkbox.temp
Saving to C:/zcosas/cocos2d/TilesV3a/.sdkbox_packages.json from .sdkbox_package
s.json.xCmh0HWf.sdkbox.temp
Creating backup archive C:/zcosas/cocos2d/TilesV3a/backup-2016-03-29.zip
Backup Completed.
skipped xcode_add_compiler_flag -DSDKBOX_ENABLED
skipped android_add_key_value 2 LOCAL_CPPFLAGS -DSDKBOX_ENABLED None
skipped config_merge_section C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.
1.2.7/plugin/sdkbox_config.json.sample C:/zcosas/cocos2d/TilesV3a/res/sdkbox_con
fig.json
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/ios/sdkbox.framework C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.io
s_mac/sdkbox.framework
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/ios/PluginFacebook.framework C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src
/proj.ios_mac/PluginFacebook.framework
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/ios/FBSDKCoreKit.framework C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/p
roj.ios_mac/FBSDKCoreKit.framework
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/ios/FBSDKLoginKit.framework C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/
proj.ios_mac/FBSDKLoginKit.framework
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/ios/FBSDKShareKit.framework C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/
proj.ios_mac/FBSDKShareKit.framework
skipped xcode_add_framework sdkbox.framework
skipped xcode_add_framework PluginFacebook.framework
skipped xcode_add_framework FBSDKCoreKit.framework
skipped xcode_add_framework FBSDKLoginKit.framework
skipped xcode_add_framework FBSDKShareKit.framework
skipped xcode_add_framework Security.framework
skipped xcode_add_framework AdSupport.framework
skipped xcode_add_framework SystemConfiguration.framework
copy C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugin/android/lib
s/sdkbox.jar to C:/zcosas/cocos2d/TilesV3a/frameworks/js-bindings/cocos2d-x/coco
s/platform/android/java/libs/sdkbox.jar
copy C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugin/android/lib
s/PluginFacebook.jar to C:/zcosas/cocos2d/TilesV3a/frameworks/js-bindings/cocos2
d-x/cocos/platform/android/java/libs/PluginFacebook.jar
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/android/jni/sdkbox C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/proj.andr
oid/jni/sdkbox
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/android/jni/pluginfacebook C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/p
roj.android/jni/pluginfacebook
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/android/libs/facebook_lib C:/zcosas/cocos2d/TilesV3a/frameworks/js-bindings/co
cos2d-x/cocos/platform/android/java/libs/facebook_lib
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/PluginFacebookJS.cpp C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-
src/Classes/PluginFacebookJS.cpp
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/PluginFacebookJS.hpp C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-
src/Classes/PluginFacebookJS.hpp
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/PluginFacebookJSHelper.cpp C:/zcosas/cocos2d/TilesV3a/frameworks/ru
ntime-src/Classes/PluginFacebookJSHelper.cpp
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/PluginFacebookJSHelper.h C:/zcosas/cocos2d/TilesV3a/frameworks/runt
ime-src/Classes/PluginFacebookJSHelper.h
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/SDKBoxJSHelper.cpp C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-sr
c/Classes/SDKBoxJSHelper.cpp
skipped copy_file C:/Users/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/plugi
n/jsbindings/SDKBoxJSHelper.h C:/zcosas/cocos2d/TilesV3a/frameworks/runtime-src/
Classes/SDKBoxJSHelper.h
skipped xcode_add_source PluginFacebookJS.cpp
skipped xcode_add_source PluginFacebookJS.hpp
skipped xcode_add_source PluginFacebookJSHelper.cpp
skipped xcode_add_source PluginFacebookJSHelper.h
skipped xcode_add_source SDKBoxJSHelper.cpp
skipped xcode_add_source SDKBoxJSHelper.h
skipped android_add_source ../../Classes/PluginFacebookJS.cpp
skipped android_add_source ../../Classes/PluginFacebookJS.hpp
skipped android_add_source ../../Classes/PluginFacebookJSHelper.cpp
skipped android_add_source ../../Classes/PluginFacebookJSHelper.h
skipped android_add_source ../../Classes/SDKBoxJSHelper.cpp
skipped android_add_source ../../Classes/SDKBoxJSHelper.h
skipped android_set_permission INTERNET False
skipped android_add_library_reference C:/zcosas/cocos2d/TilesV3a/frameworks/js-
bindings/cocos2d-x/cocos/platform/android/java/libs/./facebook_lib
skipped android_studio_add_module facebook_lib C:/zcosas/cocos2d/TilesV3a/frame
works/js-bindings/cocos2d-x/cocos/platform/android/java/libs/./facebook_lib
skipped android_add_activity com.facebook.FacebookActivity android:configChange
s=keyboard|keyboardHidden|screenLayout|screenSize|orientation android:theme=@and
roid:style/Theme.Translucent.NoTitleBar android:label=@string/app_name
skipped android_add_element application, meta-data, {'name': 'com.facebook.sdk.
ApplicationId', 'value': '@string/facebook_app_id'}, None
skipped android_add_element application, provider, {'authorities': 'com.faceboo
k.app.FacebookContentProvider_replace_with_your_app_id_', 'name': 'com.facebook.
FacebookContentProvider', 'exported': 'true'}, None
skipped android_set_element application None {'hardwareAccelerated': 'true'} No
ne False
skipped android_add_static_library PluginFacebook
skipped android_add_static_library sdkbox
skipped android_add_call import-add-path, $(LOCAL_PATH)
skipped android_add_call import-module, ./sdkbox
skipped android_add_call import-module, ./pluginfacebook
skipped android_add_string facebook_app_id your_app_id
skipped android_add_key_value 2 LOCAL_LDLIBS -landroid None
skipped android_add_key_value 2 LOCAL_LDLIBS -llog None
skipped android_set_key_value 3 target android-15
skipped patch_file Cocos2dxActivity.java
skipped patch_file AppDelegate.cpp
Please reference the online documentation to finish the integration:
http://sdkbox-doc.github.io/en/plugins/facebook/v3-js/
Installation Successful :)
Performing at_exit cleanup.
Tracking: {'cocos_installation': '3.5.0', 'sdkbox_version': '1.0.0.9', 'cocos':
'3.5.0', 'args': {'verbose': 2, 'installer': 'C:/zcosas/android-soft/sdkbox_ins
taller/sdkbox.pyc', 'manifest': 'manifest.json', 'nopatching': 1, 'patcherrors':
0, 'project': 'C:/zcosas/cocos2d/TilesV3a/', 'noupdate': 0, 'mvalue': None, 'no
patchingcpp': 0, 'local': 0, 'nohelp': 0, 'dryrun': None, 'jsonapi': 0, 'symbol'
: None, 'china': 0, 'mkey': None, 'info': None, 'remote': 0, 'plugin': u'C:/User
s/oscar/.sdkbox/plugins/sdkbox-facebook_v2.1.2.7/', 'forcecopy': 0, 'days': 10,
'server': 'download.sdkbox.com/installer/v1/', 'forcedownload': 0, 'command': 'i
mport', 'alwaysupdate': 0}, 'return_status': 'success'}
C:\zcosas\cocos2d\TilesV3a>
I did the last steps of integration of the plugin, and the with the AppDelegate.cpp modifications. I also checked the manual integration steps.
The sdkbox-config.json is in res/ folder
But i get this error…
And i using the last version so the conflict with PluginWrapper is not possible cause.
I use cocos2djs-3.5 with cocos IDE.
thanks for the help
Hey @opalfonso
I guess the patching failed for AppDelegate.cpp
due to some reason.
please cross check your AppDelegate.cpp
with the one in the sample.
It’s just couple of lines of code that the patch introduces into the project at AppDelegate.cpp
https://github.com/sdkbox/sdkbox-facebook-sample
Best,
Pabitra
There are some more differences, but the relevant (as i understand with the instrucctions of the manual integration of the sdkbox facebook plugin) are ok, i refer to :
add :
#include "PluginFacebookJS.hpp"
#include "PluginFacebookJSHelper.h"
add :
sc->addRegisterCallback(register_all_PluginFacebookJS);
sc->addRegisterCallback(register_all_PluginFacebookJS_helper);
Maybe i have some error ?, Here is my AppDelegate.cpp file :
$ cat AppDelegate.cpp
#include "AppDelegate.h"
#include "SimpleAudioEngine.h"
#include "jsb_cocos2dx_auto.hpp"
#include "jsb_cocos2dx_ui_auto.hpp"
#include "jsb_cocos2dx_studio_auto.hpp"
#include "jsb_cocos2dx_builder_auto.hpp"
#include "jsb_cocos2dx_spine_auto.hpp"
#include "jsb_cocos2dx_extension_auto.hpp"
#include "jsb_cocos2dx_3d_auto.hpp"
#include "jsb_cocos2dx_3d_extension_auto.hpp"
#include "3d/jsb_cocos2dx_3d_manual.h"
#include "ui/jsb_cocos2dx_ui_manual.h"
#include "cocostudio/jsb_cocos2dx_studio_manual.h"
#include "cocosbuilder/js_bindings_ccbreader.h"
#include "spine/jsb_cocos2dx_spine_manual.h"
#include "extension/jsb_cocos2dx_extension_manual.h"
#include "localstorage/js_bindings_system_registration.h"
#include "chipmunk/js_bindings_chipmunk_registration.h"
#include "jsb_opengl_registration.h"
#include "network/XMLHTTPRequest.h"
#include "network/jsb_websocket.h"
#include "network/jsb_socketio.h"
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include "platform/android/CCJavascriptJavaBridge.h"
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
#include "platform/ios/JavaScriptObjCBridge.h"
#endif
#include "CodeIDESupport.h"
#include "Runtime.h"
#include "ConfigParser.h"
//oscar
#include "PluginFacebookJS.hpp"
#include "PluginFacebookJSHelper.h"
USING_NS_CC;
using namespace CocosDenshion;
AppDelegate::AppDelegate()
{
}
AppDelegate::~AppDelegate()
{
ScriptEngineManager::destroyInstance();
#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
endRuntime();
#endif
ConfigParser::purge();
}
void AppDelegate::initGLContextAttrs()
{
GLContextAttrs glContextAttrs = {8, 8, 8, 8, 24, 8};
GLView::setGLContextAttrs(glContextAttrs);
}
bool AppDelegate::applicationDidFinishLaunching()
{
#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
initRuntime();
#endif
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
Size viewSize = ConfigParser::getInstance()->getInitViewSize();
string title = ConfigParser::getInstance()->getInitViewName();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32 || CC_TARGET_PLATFORM == CC_PLATFORM_MAC) && (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
extern void createSimulator(const char* viewName, float width, float height,bool isLandscape = true, float frameZoomFactor = 1.0f);
bool isLanscape = ConfigParser::getInstance()->isLanscape();
createSimulator(title.c_str(), viewSize.width,viewSize.height, isLanscape);
#else
glview = cocos2d::GLViewImpl::createWithRect(title.c_str(), Rect(0, 0, viewSize.width, viewSize.height));
director->setOpenGLView(glview);
#endif
}
// set FPS. the default value is 1.0/60 if you don't call this
director->setAnimationInterval(1.0 / 60);
ScriptingCore* sc = ScriptingCore::getInstance();
sc->addRegisterCallback(register_all_cocos2dx);
sc->addRegisterCallback(register_cocos2dx_js_core);
sc->addRegisterCallback(jsb_register_system);
// extension can be commented out to reduce the package
sc->addRegisterCallback(register_all_cocos2dx_extension);
sc->addRegisterCallback(register_all_cocos2dx_extension_manual);
// chipmunk can be commented out to reduce the package
sc->addRegisterCallback(jsb_register_chipmunk);
// opengl can be commented out to reduce the package
sc->addRegisterCallback(JSB_register_opengl);
// builder can be commented out to reduce the package
sc->addRegisterCallback(register_all_cocos2dx_builder);
sc->addRegisterCallback(register_CCBuilderReader);
// ui can be commented out to reduce the package, attension studio need ui module
sc->addRegisterCallback(register_all_cocos2dx_ui);
sc->addRegisterCallback(register_all_cocos2dx_ui_manual);
// studio can be commented out to reduce the package,
sc->addRegisterCallback(register_all_cocos2dx_studio);
sc->addRegisterCallback(register_all_cocos2dx_studio_manual);
// spine can be commented out to reduce the package
sc->addRegisterCallback(register_all_cocos2dx_spine);
sc->addRegisterCallback(register_all_cocos2dx_spine_manual);
// XmlHttpRequest can be commented out to reduce the package
sc->addRegisterCallback(MinXmlHttpRequest::_js_register);
// websocket can be commented out to reduce the package
sc->addRegisterCallback(register_jsb_websocket);
// sokcet io can be commented out to reduce the package
sc->addRegisterCallback(register_jsb_socketio);
// 3d can be commented out to reduce the package
sc->addRegisterCallback(register_all_cocos2dx_3d);
sc->addRegisterCallback(register_all_cocos2dx_3d_manual);
// 3d extension can be commented out to reduce the package
sc->addRegisterCallback(register_all_cocos2dx_3d_extension);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(JavascriptJavaBridge::_js_register);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS|| CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
sc->addRegisterCallback(JavaScriptObjCBridge::_js_register);
#endif
// oscar
sc->addRegisterCallback(register_all_PluginFacebookJS);
sc->addRegisterCallback(register_all_PluginFacebookJS_helper);
#if (COCOS2D_DEBUG > 0 && CC_CODE_IDE_DEBUG_SUPPORT > 0)
// NOTE:Please don't remove this call if you want to debug with Cocos Code IDE
startRuntime();
#else
sc->start();
sc->runScript("script/jsb_boot.js");
auto engine = ScriptingCore::getInstance();
ScriptEngineManager::getInstance()->setScriptEngine(engine);
ScriptingCore::getInstance()->runScript(ConfigParser::getInstance()->getEntryFile().c_str());
#endif
return true;
}
// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
void AppDelegate::applicationDidEnterBackground()
{
auto director = Director::getInstance();
director->stopAnimation();
director->getEventDispatcher()->dispatchCustomEvent("game_on_hide");
SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
SimpleAudioEngine::getInstance()->pauseAllEffects();
}
// this function will be called when the app is active again
void AppDelegate::applicationWillEnterForeground()
{
auto director = Director::getInstance();
director->startAnimation();
director->getEventDispatcher()->dispatchCustomEvent("game_on_show");
SimpleAudioEngine::getInstance()->resumeBackgroundMusic();
SimpleAudioEngine::getInstance()->resumeAllEffects();
}