Download and Install Cocos2d-x Tutorial

In this post, we’ll get things up and running cocos2d-x in our machine. This will include information on downloading the framework and creating a project as well as an overview of the basic structure of a Cocos2d-x application.

I will also point you to some extra tools you should consider getting to help you with the development process.

Downloading Cocos2d-x Manual

I recommend that you save all the files we are going to download now to the same folder
  1. Go to cocos2d-x download site and download lastest version of cocos2d-x, for this tutorial, I will be using version Cocos2d-x 3.17-2.
  2. When download complete, uncompress the files somewhere in your machine so you can remember later.
  3. Open folder you just uncompress and view the file, find Build Requirements header and you can see python, NDK, android studio, Xcode and JDK version is required to build games.
  4. Then go to python site to download python.
  5. If your machine run Mac OS you need install XCode.
  6. If you haven’t JDK in your machine, go to oracle site and install JDK.
  7. Next go to android developer site to install Android Studio.
  8. Lastly, go to ndk site and download the latest version of the NDK for your target system.

Installing Cocos2d-x

  1. You can do this by typing cd (that is, cd and a space) and then dragging the folder to the Terminal window and hitting Enter. In my machine this looks like: cd /Applications/Dev/cocos2d-x-3.17-2
  2. Next typy python
  3. Hit Enter. You will be prompted for the paths to the NDK, SDK and Apache ANT root. You must drag each one of the folders to the Terminal window, making sure to delete any extra spaces at the end of the path and hit Enter.
  4. If your use Mac, the last step is to add these paths to your system. Follow the last instruction in the window where it says: Please execute command: “source /Users/YOUR_USER_ NAME/.bash_profile” to make added system variables take effect. You can copy the command inside the quotes, paste it, and hit Enter.

Hello Cocos2d-x World

Now, it’s time for test your installing, say hello to cocos2d-x

You can create a new Cocos2d-x Project by run cocos script
$ cd cocos2d-x
$ ./
$ cocos new MyGame -p com.your_company.mygame -l js -d NEW_PROJECTS_DIR

Then hit Enter. If you choose not to give a directory parameter (-d), the Cocos console will save the project inside your current folder. You also can create a C++ project or Lua project with `-l cpp` or `-l lua`. You can replace NEW_PROJECTS_DIR with other folder name that you prefer.

Run Your Game

Now you can go to your desktop, or wherever you chose to save your project, and navigate to the MyGame folder. Now you can run your game depend of your target runtime system, you run script respectively.

Build and run a new project for iOS
$ cocos run -p ios

Build and run a new project for OSX
$ cocos run -p mac

Build and run new project for win32
$ cocos run -p win32

Build and run new project for web
$ cocos run -p web

And you’re done.

MyGame Project
If you see any issue or error from beyond process, Share your thoughts in the comments below :D, thank you.

Life teaches us through our mistakes.

Haemin Sunim

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s