We are trying to transition a project from C++ to JS. How can we plan to implement ‘some’ modules in Cocos2dx JS one by one, while still using the other existing code written in Cocos2dx C++.
Can we use C++ and Javascript modules together? One possibility might be to write JSB bindings for our C++ modules/scenes/classes etc and then implement a ‘empty’ Cocos2dx JS project which only uses the C++ modules using the bindings. And then we can slowly implement individual modules in JS. Will this work?
Any other options?
Our main reason to move everything from C++ to JS is to be able to run in browser too. And we are also hoping that JS code will be easier to work with in the longer run. Does the Coco2dx HTML5/JS version has all the same features as C++/JSB version with same/similar behavior? Or will it better to just reimplement everything in Cocos2dx HTML/JS instead of trying to transition existing C++ implementation to JS module by module?
JSB bindings won’t work in HTML, so you’ll need to create the implementation in javascript as well. I think it’ll be easier to just reimplement everything in javascript. Regarding having the same features, the js version has all the basics from the c++ version. A nice overview can be found in the tests. There are some differences between JSB and the HTML version as well, but nothing spectacular.
You would need to rewrite the game completely in JS in order for it to run in a browser. The HTML5 version is pure JS and makes no calls to the C++ code. When running on a PC/mobile device, your JS code uses JSB bindings.
Like araker said, the two versions are mostly the same. You do have to be a little careful though, because sometimes you can run into problems if you’re trying to customize cocos2d-js to your specific needs (e.g. subclassing cocos2d classes). The more I work with cocos2d-js, the more I find it helpful to understand where it makes JSB calls and where it doesn’t, when running in native.