4

I am evaluating to switch from CoronaSDK to Cocos2D for cross platform development.

The main requirement is that I need to be able to include native libraries for iOS and Android. I have come across How To Integrate a 3rd party SDK into Plugin-X, but I am not sure if and how this would apply to Cocos2D-JS.

How can native 3rd party libraries (like ad network SDKs) be integrated into a Cocos2D-JS project, that will get compiled into native iOS and Android apps? Anybody with experiences or best practices?

CodeSmile
  • 64,284
  • 20
  • 132
  • 217
thomers
  • 2,603
  • 4
  • 29
  • 50
  • 1
    The biggest issues I have seen in this area revolves around view controllers and making their the UIView/UIViewController created by the ad network plays well with the views created in your own project. Have you tried any of the actual integration work? In terms of viability seems like this should be possible but haven't fully tried so I don't know. Best to do a small test project and see if you run into any major issues. – Rob Segal Jun 23 '14 at 15:38
  • Thanks Rob - actually, I'm not even sure where/how to begin. Is Plugin-X relevant for Cocos2D-JS? Anything else? – thomers Jun 23 '14 at 16:55
  • I guess my question is regardless of the specific needs for of Ad Networks (like problems with view controllers). What is the "official" way to integrate 3rd party libraries with Cocos2D-JS or Cocos2D - and what is the difference between the two? – thomers Jun 24 '14 at 09:55
  • 1
    I'm not sure this will be relevant to you, but here's another question that may give you some leads: http://stackoverflow.com/questions/24006441/can-an-embedded-cocos2d-js-app-call-back-out-to-c (I haven't done any plugin integration work yet, sorry) – Sebastián Vansteenkiste Jun 24 '14 at 14:14
  • @RobSegal would you have any starting point for me? It seems the documentation for this topics is really lacking... The JSB-documentation I found so far talks about "automatic" creation of the glue code. The Plugin-X wiki pages are mostly empty, or refer to Cocos2D-X and not the Cocos2D-JS "layer" on top. – thomers Aug 09 '14 at 10:01
  • @thomers I would expect as a starting point following code execution through Xcode for an existing sample project would prove fairly insightful. Pick something simple like how a scene created in JavaScript gets executed on the code side. You should be able to expand on this creating your own extension to the API on the JavaScript side for whatever you want to do really. – Rob Segal Aug 12 '14 at 20:16

1 Answers1

1

That would work like normal native lib integration. For example. You want to integrate Firebase for Android platform.

What you will do is open the Android cocos project into your favorite Android editor and write native code, you can make calls to Java functions you have defined by using JSB which is a mechanism provided by Cocos2d-JS to call native functions from JS code.

When you build for Android, your lib for Firebase and code will get compiled perfectly.

Same is the case if you want to do for iOS.

Cocos2d also has support for SDKBox which has many third-party services SDK already implemented for you for both iOS and Android.