Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Cocos2d-x cookbook

You're reading from   Cocos2d-x cookbook Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-x

Arrow left icon
Product type Paperback
Published in Nov 2015
Publisher
ISBN-13 9781783284757
Length 254 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Akihiro Matsuura Akihiro Matsuura
Author Profile Icon Akihiro Matsuura
Akihiro Matsuura
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Getting Started with Cocos2d-x FREE CHAPTER 2. Creating Sprites 3. Working with Labels 4. Building Scenes and Layers 5. Creating GUIs 6. Playing Sounds 7. Working with Resource Files 8. Working with Hardware 9. Controlling Physics 10. Improving Games with Extra Features 11. Taking Advantages Index

Installing Cocos2d-x

Getting ready

To follow this recipe, you need to download the zip file from the official site of Cocos2d-x (http://www.cocos2d-x.org/download).

At the time of writing this book, version 3.4 was the latest stable version that was available. This version will be used throughout this book.

How to do it...

  1. Unzip your file to any folder. This time, we will install the user's home directory. For example, if the user name is syuhari, then the install path is /Users/syuhari/cocos2d-x-3.4. In this book, we call it COCOS_ROOT.
  2. The following steps will guide you through the process of setting up Cocos2d-x:
    • Open the terminal
    • Change the directory in terminal to COCOS_ROOT, using the following command:
      $ cd ~/cocos2d-x-v3.4
      
    • Run setup.py, using the following command:
      $ ./setup.py
      
    • The terminal will ask you for NDK_ROOT. Enter into NDK_ROOT path.
    • The terminal will then ask you for ANDROID_SDK_ROOT. Enter the ANDROID_SDK_ROOT path.
    • Finally, the terminal will ask you for ANT_ROOT. Enter the ANT_ROOT path.
    • After the execution of the setup.py command, you need to execute the following command to add the system variables:
      $ source ~/.bash_profile
      

      Tip

      Open the .bash_profile file, and you will find that setup.py shows how to set each path in your system. You can view the .bash_profile file using the cat command:

      $ cat ~/.bash_profile
      
  3. We now verify whether Cocos2d-x can be installed:
    • Open the terminal and run the cocos command without parameters:
      $ cocos
      
    • If you can see a window like the following screenshot, you have successfully completed the Cocos2d-x install process:
    How to do it...

How it works...

Let's take a look at what we did throughout the above recipe. You can install Cocos2d-x by just unzipping it. You know setup.py is only setting up the cocos command and the path for Android build in the environment. Installing Cocos2d-x is very easy and simple. If you want to install a different version of Cocos2d-x, you can do that too. To do so, you need to follow the same steps that are given in this recipe, but they will be for a different version.

There's more...

Setting up the Android environment is a bit tough. If you recently started to develop Cocos2d-x, you can skip the settings part of Android. and you can do it when you run on Android. In this case, you don't have to install Android SDK, NDK, and Apache ANT. Also, when you run setup.py, you only press Enter without entering a path for each question.

You have been reading a chapter from
Cocos2d-x cookbook
Published in: Nov 2015
Publisher:
ISBN-13: 9781783284757
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime
Banner background image