In this tutorial I am going to discuss about how to create an application using cocos2d-x version 3.3rc0.
At first, Download and setup the environment necessary for developing cocos2d-x application.
Go to the following link and download the latest cocos2d-x. Right now, the latest version is 3.3rc0.
Make sure you have Xcode, Android SDK and NDK, ANT in your system. Once you have downloaded all the necessary softwares let’s move to the next step.
Now we will move to the cocos2d-x folder. Open terminal application and go to the cocos2d-x folder using the cd command. You can do it in a very simple way. write cd in the terminal and drag and drop the “cocos2d-x-3.3rc0” folder in the terminal. Then hit enter/return. This is how it will look like,
We are inside the cocos2d-x-3.3rc0 folder. The next step is to execute the setup.py file. Execute the following command in your terminal.
If everything goes ok then your terminal application window will look like below.
Look at the above image carefully. If in your terminal you can see “COCOS_CONSOLE_ROOT is found”, “NDK_ROOT is found”, “ANDROID_SDK_ROOT is found”, “ANT_ROOT is found” then you are good to proceed to the next step. If not then you can manually correct their path too.
To correct the paths of the above softwares manually you need to execute the following command in your terminal.
touch ~/.bash_profile; open ~/.bash_profile
This line of command will open the .bash_profile file and you can correct or add the paths there manually.
Now you have to execute the following command from the terminal.
This line of command will save any kind of changes you made to the .bash_profile file.
Now it’s time to create our cocos2d-x project. In order to do so, execute the following command from your terminal.
cocos new ProjectName -d ~/Documents -p com.findsourcecode.ProjectName -l cpp
Once you execute the command you will see a new project named “ProjectName” in your Documents folder. On the command above -d stands for directory and -l stands for the language of this project which is C++.
Now it’s time to run our project or application. There are two ways to do this. You can run it from the terminal application or run it from Xcode. To run your cocos2d-x application from terminal application execute the following command.
cocos run -s ~/Documents/ProjectName/ -p ios
In the command above -p stands for platform.
To run your application from Xcode go to ProjectName/proj.ios_mac folder. There you can see ProjectName.xcodeproj. Double click on it and it will open in Xcode. Then run the application from Xcode.
This is how you can create application using cocos2d-x v3.3rc0. If you have any questions feel free to ask me in the comment section.
In the next tutorial we will talk about how to create webview in cocos2d-x application.
- Webview in Cocos2d-x v3.3rc0 - November 14, 2014
- How to create application using Cocos2d-x v3.3 - November 12, 2014
- Animated progress bar in CSS, jQuery - October 24, 2014
- Sudoku Checker in C Programming - September 30, 2014