This article mainly records the environment setup on the android platform. The operating system I use is ubuntu 10.10, and the program is implemented in c ++ instead of java.
1. Download and install
I chose the cocos2d-1.0.1-x-0.12.0 version,
Decompress the package to the desired workspace.
After decompression, we need to modify the android ndk and sdk path (to your own sdk and ndk path), modify in the create-android-project.sh,
2. Generate the HelloWorld Project
In fact, there is already a HelloWorld project under the decompressed Directory, which includes versions of multiple platforms. However, to record its principles, we still need to generate a project by ourselves, in the future, all the new game projects will need to provide us with a game framework through their script programs, and then we will enrich it according to the needs of the game.
Command to enter the cocos2d-x decompressed directory,
Those who have shell experience may soon understand, those different. sh scripts are to help us create a project template, run the command:./create-android_project.sh
We will be prompted to enter the project package name,
You can enter the usual package name rule. I entered onerain. hello.
The selected version will be displayed later, that is, the corresponding android version, but it is different from the corresponding relationship when we create the android project. You can take a closer look, here I choose android-7, the corresponding number is 3.
Then, enter the project name,
I entered HelloCocos2dx (PS: HelloWorld already exists ).
Show the current file, you will find a HelloCocos2dx directory, This Is The cocos2d-x we just created android template project
Show the current file, you will find a HelloCocos2dx directory, This Is The cocos2d-x we just created android template project
3. eclipse Import
Create an android project in eclipse, select an existing project, and find the android directory under the HelloCocos2dx project directory just created,
It cannot be run at this time. Please be patient...
4. ndk compilation. Because the shell script generates a c ++ file for us, we need to compile it into android. the o Library is then called through jni in android to implement cross-platform implementation.
Enter the android directory of the project you just created in the command line, and
We can see a shell script again. Right, this is the script that helps us generate the. o library. Run the command./build_native.sh while confirming that the ndk has been configured successfully.
If it succeeds, the compilation process will take about dozens of seconds.
OK, so that you can refresh the eclipse project. After everything is successful, the libs directory will appear under the project directory,
If everything goes well, running your project will get a gorgeous HelloWorld,
Author: oneRain88