Page 1 of 1

Integrate Smartfox to cocos2d-js

Posted: 03 Aug 2016, 09:53
by caldelta
Hello,

I am going to integrate smartfox to cocos2d-js, but i face some issues need to make clear.

Currently, i have successful intergate smartfox to cocos2d-x ( using c++ client api)

Now I need integrate it to cocos2d-js too. My expectation is I only need to write ONCE by javascript and able to compile on 3 platform html5, android and ios.

Cocos2d-js provide a solution to binding Js to C++, but SmartFox using boost library which is so complicate for binding-generator ( I guess so). I stuck on binding boost lib just now.

I know many people here are success to integrate it. Please help with with some advice or a right direction. Thank you!

Best regards,

Re: Integrate Smartfox to cocos2d-js

Posted: 03 Aug 2016, 14:28
by Lapo
Hi,
if you're using Cocos2D-JS you should also use our Javascript client library. Not the C++ one.

You can go to our main download page, and download it:
http://smartfoxserver.com/download/sfs2x#p=client

The library is written in pure javascript and works very similarly to the other SmartFoxServer API. I would also recommend downloading our HTML5 Example Pack here:
http://smartfoxserver.com/download/sfs2x#p=examples

The Javascript documentation is found here:
http://docs2x.smartfoxserver.com/api-docs/jsdoc/

cheers

Re: Integrate Smartfox to cocos2d-js

Posted: 04 Aug 2016, 02:16
by caldelta
Hi there,

How about 2 native: android and ios but use javascript as the developing language?

Re: Integrate Smartfox to cocos2d-js

Posted: 04 Aug 2016, 05:14
by Lapo
Hi,
I am not an expert of Cocos2D-JS specifically, but the idea is that Cocos allows you to write your code in Javascript and then will compile your project for various platforms, including iOS and Android. Right?

If this is correct then our HTML5/JS library is pure Javascript code so it can compiled, along with your game JS code, to any of the platforms supported by Cocos2D-JS.

At least this is what I understand from this page:
http://www.cocos2d-x.org/wiki/Cocos2d-JS

cheers

Re: Integrate Smartfox to cocos2d-js

Posted: 04 Aug 2016, 10:09
by caldelta
Yes, HTML5/JS library is pure Javascript therefore It is only work on WEB not on NATIVE Android and iOS.

Cocos2d-js provide a mechanism called "jsb" allow javascript call native API.

I wonder if i could use JSB to call native API of smartfox too ?

Re: Integrate Smartfox to cocos2d-js

Posted: 04 Aug 2016, 14:08
by Lapo
Yes, I suppose that is possible.

Re: Integrate Smartfox to cocos2d-js

Posted: 05 Aug 2016, 04:13
by caldelta
Do you have plan to support it officially ? :(

Re: Integrate Smartfox to cocos2d-js

Posted: 05 Aug 2016, 06:55
by Lapo
I am not sure what you mean by that. If Cocos2D-JS can call native code you can use the official C++ API.

Sure the operation sounds a little bit convoluted since you have to write JS code for HTML and then wrap the native API calls... honestly it seems a bit of a convoluted system.

Why not using Cocos2D-x directly for the mobile versions? It seems like an easier process than wrapping all the JS code which calls the native code below... Just my impression.

cheers

Re: Integrate Smartfox to cocos2d-js

Posted: 05 Aug 2016, 08:39
by caldelta
yes, as you said that is convoluted progress.

By using JSB to allow javascript call native API have some limitations. And the boost library which is not simple C++ library for binding generator already. I was try to binding boost lib C++ first then your "Wrapper Smartfox" . But stuck at "boost binding process".

We intented to use Javascript to save time of developing, only write ONCE LOGIC and compile in various platforms. Of course using cocos2d-x separately is easier process.