Cocos2d-JS v3.6 is released!

Hi pandamicro,
I am trying to integrate Facebook SDK by using the guidance given in the following URL

http://www.cocos2d-x.org/docs/manual/framework/html5/facebook-sdk/facebook-sdk-on-android/en10

I have correctly followed all the configuration and I tried to get the instance of FacebookAgent by

using the statement

var facebook = plugin.FacebookAgent.getInstance();

This results in error: ReferenceError: plugin is not defined

I have also included ‘extensions’ in the project.json file, but can’t able to activate plugin.
Is there any other settings to be done to enable plugins? please guide me here
debug info﹕ JS: assets/src/app.js:15:ReferenceError: plugin is not defined

You need to import jsb_pluginx.js also into your project and require it in jsb.js.

thank you so much “pandamicro” i solved it.
anyone have the same problem you need to import jsb_plugin.js .
Note : you just need to retype your code correctly .

Add the following lines in your ProjectRoot/frameworks/runtime-src/proj.android/jni/Android.mk.
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_pluginx_static
$(call import-module,cocos2d-x/plugin/jsbindings)
Here’s the sample of that.

LOCAL_STATIC_LIBRARIES := cocos_jsb_static
LOCAL_WHOLE_STATIC_LIBRARIES += jsb_pluginx_static
LOCAL_EXPORT_CFLAGS := -DCOCOS2D_DEBUG=2 -DCOCOS2D_JAVASCRIPT

include $(BUILD_SHARED_LIBRARY)

$(call import-module,bindings)
$(call import-module,cocos2d-x/plugin/jsbindings)

NextStep. Now in the same jni directory i.e. ProjectRoot/frameworks/runtime-src/proj.android/jni/ you will find hellojavascript/main.cpp

Add the import lines at the top
#include “PluginJniHelper.h”
Add the following code under cocos_app_init function
JavaVM* vm;
env->GetJavaVM(&vm);
PluginJniHelper::setJavaVM(vm);

       your function should look like this

      void cocos_android_app_init (JNIEnv* env, jobject thiz) {
       LOGD("cocos_android_app_init");
       AppDelegate *pAppDelegate = new AppDelegate();
JavaVM* vm;
       env->GetJavaVM(&vm);
       PluginJniHelper::setJavaVM(vm);
      }

NextStep. Now go to this directory ProjectRoot/frameworks/runtime-src/Classes/AppDelegate.cpp

Add the following code at the top to #include the two files
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
#include “jsb_cocos2dx_pluginx_auto.hpp”
#include “jsb_pluginx_extension_registration.h”
#endif
This is very important step , see the below code which you need to add inside the function
bool AppDelegate::applicationDidFinishLaunching() but remember to add before js_register as shown below.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
sc->addRegisterCallback(register_all_pluginx_protocols);
sc->addRegisterCallback(register_pluginx_js_extensions);
#endif

#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

NextStep. Add the following lines in the ProjectRoot/frameworks/runtime-src/proj.android/build-cg.json
basically copy the protocols src and googlelPlay src to the project

“copy_resources”: [
{
“from”: “…/…/…/src”,
“to”: “src”
},
{
“from”: “…/…/…/res”,
“to”: “res”
},
{
“from”: “…/…/…/main.js”,
“to”: “”
},
{
“from”: “…/…/js-bindings/cocos2d-x/plugin/jsbindings/script”,
“to”: “”
},
{
“from”: “…/…/js-bindings/cocos2d-x/plugin/protocols/proj.android/src”,
“to”: “…/src”
},
{
“from”: “…/…/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.android/src”,
“to”: “…/src”
},
{
“from”: “…/…/js-bindings/cocos2d-x/plugin/plugins/facebook/proj.android/sdk”,
“to”: “…/libs”
}
],
what i wrote here not fully steps , but important to retype
but anyone need full steps please refer to this link
http://www.cocos2d-x.org/wiki/Integrate_Facebook_SDK_on_Android

1 Like

Any chance a Cocos2d-JS version of a faster (and more importantly: smaller memory footprint) version of TMXTiledMap will make it into 3.7?

Tilemaps right now take huge amounts of memory because every tile is a cc.Sprite (a 20x20 map with a couple of layers is almost 4 megabytes).

1 Like

I’m unable to create new thread so i’ll try to ask there.
So i want to make game with network support(client-server). Is there way to make client network interaction in cocos2d-js?

Linux support has been broken since 3.6. The command “cocos run -p linux” fails on Ubuntu 12.04 because of mistakes in frameworks/js-bindings/cocos2d-x/external/freetype2/include/linux/freetype/config/ftheader.h . In cocos2d-js 3.6 and later there’re wrong includes.

I think that this error will raise on all linux machines.