HTML and CSS Reference
In-Depth Information
there are five steps that need to be taken to set up the eclipse environment for Cocos2d-x. let's set up the
COCOS2DX
and
NDK_ROOT
variables before adding the existing project to eclipse in this section. (skip the first two
steps if you've done this before.)
1.
open
Eclipse>Preference>General>Workspace>Linked Resources
, and click the
New
button to add the path Variable
COCOS2DX
pointing to the root Cocos2d-x.
2.
open
Eclipse>Preferences>C/C++>Build>Environment
, and click the
Add
button to add a
new variable
NDK_ROOT
pointing to the root android ndK directory.
3.
now let's add the libCocos2dx library project and the game project. open
File>New>Project>Android Project From Existing Code
, and click the
Browse
button.
4.
open the
~/work/HalloweenDefence/Cocos2d-x-2.2.2/Cocos2dx/platform/android/
java
directory, and click
Finish
to add the project.
5.
open
File>New>Project>Android Project From Existing Code
, click
Browse
to go
to your project directory,
~/work/HalloweenDefence/Cocos2d-x-2.2.2/projects/
HalloweenDefence/proj.android
, and add the project.
As Listing 24-25 shows, you created the Android projects, and added the game resources to Cocos2d JSB project.
Now everything is ready, and you can build and run the game on Android devices or an emulator.
Figure
24-25
shows the Hybrid Project screen for Android. You can get the same game in your Android device.
Figure 24-25.
Hybrid Project screen for Android