HTML and CSS Reference
In-Depth Information
Releasing a Cocos2d-html5 App to a Native App
Cocs2d-html5 and Cocos2d JSB have the same set of completely compatible JavaScript APIs. Thus a Cocos2d-html5
project can easily be run on HTML5-ready browsers. It also supports running game code as a native application via
the Cocos2d JSB without code modification.
The Power of Distributing an HTML5 Game as a Native Package
Cocos2d JSB for C/C++ is the wrapper code that sits between the native code and JavaScript code. JSB enables the
calling of the native code from the JavaScript code and vice versa, as illustrated in Figure 24-21 .
JavaScript code
JS Bindings layer
(C/C++ code)
Native Library
(eg: Cocos2d-x)
Figure 24-21. Cocos2d JSB
SpiderMonkey interprets JavaScript code, Mozilla's JavaScript virtual machine (VM). The JavaScript VM
is extended by JSB to support Cocos2d-x types, structures, and objects. SpiderMonkey is Mozilla's open source
JavaScript engine written in C/C++, and it can be linked into any C++ program, not just web browsers.
C++ code accesses SpiderMonkey via the JSAPI. The JSAPI provides functions for setting up the JavaScript
runtime, compiling and executing scripts, creating and examining JavaScript data structures, handling errors, enabling
security checks, and debugging scripts. You can find the Cocos2d-x JSB wrapper code under the directory [Cocos2d-x
root]/scripting/javascript/ . This technology is used for rapid game development and game prototyping.
Setting Up the Cocos2d JSB Environment
Cocos2d-x is a multi-platform 2D game engine. As an example, the porting steps that follow focus on Android and iOS.
Most of the steps for porting to these two platforms are the same, and I will point out the few differences.
Search WWH ::

Custom Search