In the previous section, the sample in the NDK can be executed normally. However, the project generated by Cocos2d-x cannot be compiled successfully. Previous stamp here: http://blog.csdn.net/xjjjjjjjjjjj/article/details/29382201
1. Create a new project
Open cmd and enter the command:
Cocos New Helloworld-p com.hello-l cpp-d E:\WorkSpace\cocos2d-x\l2\
Other platforms Create project stamps here: Http://cocos2d-x.org/wiki/How_to_Start_A_New_Cocos2D-X_Game
Start creating a new project:
After creation, the prompt is successful:
The Project Files folder is as follows:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegpqampqampqampq/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
2. Import Androidproject into eclipse
After the import, will be error, missing package,:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegpqampqampqampq/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
You need to copy the Android platform package from the Cocos2d-x download package to copy the location for example: (My location is: D:\Program files\cocos2d-x-3.1.1\cocos\platform\android\java\ Src
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegpqampqampqampq/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
After copying, it will not be an error, for example:
watermark/2/text/ahr0cdovl2jsb2cuy3nkbi5uzxqvegpqampqampqampq/font/5a6l5l2t/fontsize/400/fill/i0jbqkfcma==/ Dissolve/70/gravity/center ">
3. Compiling
Select the Helloword project and click menu Project->clean to compile only the selected items.
Compiling takes time, and so on.--------here to spit, C + + is really far worse than Java (using angle)
An error occurred while executing the project. No variables found
The second time repeatedly, too lazy to delete the variable after.
Selected items, right-click Properties
Add three variables to C++build,
Cocos2dx,ndk_root,ndk_module_path (requires COCOS2DX root folder and Android Platform folder).
At this point, the project can be executed in the real machine.
4.helloword code logic is very easy, with programming experience to look at the clear.
C + + base stamp here:
Cocos2d-x mobile game Development Essential C + + language Foundation
Cocos2d-x Novice Learning HelloWorld (third) [version number: cocos2d-x-3.1.1]