Here I see the following:

.... the team of Cocos2d-x are working on something called "Javascript binding for Cocos2d". What that means is your very same code running on Cocos2d-html5 engine can work flawlessly on Cocos2d-X and Cocos2d-iPhone without or with little modification. And all that translates to "almost native fast on mobile phones".

What I can not understnad is that how the code written in one language can be translated to another one? Do they mean that there is a tool that gets as an input JavaScript code of Cocos2d-html5 game and translate it to C++ Cocos2dx code or backwards?

EIDT: Can I port easily the C++ game written with Cocos2Dx into Cocos2D-html5? What I have to do for that?

有帮助吗?

解决方案

Cocos2d-x and Cocos2d-html5 share the same Javascript API and are written to give developer an advantage to write your code in Javascript and it will work with both of these frameworks.

As for you second question, Cocos2d-html5 runs Javascript natively whereas Cocos2d-x uses SpiderMonkey (a Javascript engine written in C/C++ by Brendan Eich) to run your Javascript code.

Although, there is one important thing to consider. Developing games using native language and APIs takes less time, easy to debug and are easily expandable and maintainable. So, in my opinion one should use cocos2d-iphone if the game is only for iOS, cocos2d-x if the game is on multi-platforms and cocos2d-html5 only if the primary target of the game is web.

其他提示

It means that both cocos2d-x and cocos2d-html use the same Javascript API. So under ideal circumstances the same JS code runs on html5 and another time with the -x engine.

However there can still be differences because behind the scenes the implementation may be subtly (or not so subtly) different with each engine. Also not all features (ie touch input, accelerometer, shaders) can be available on every engine. Hence the phrasing "with little modification".

But if your main target isn't web there's little sense in using the JS API because it adds an extra layer that makes it more difficult to debug code issues, and the overall performance suffers compared to writing directly (in C++) for -x.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top