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
Cocos2d-x cookbook
Cocos2d-x cookbook

Cocos2d-x cookbook: Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-x

Arrow left icon
Profile Icon Akihiro Matsuura
Arrow right icon
Can$34.98 Can$49.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (5 Ratings)
eBook Nov 2015 254 pages 1st Edition
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial
Arrow left icon
Profile Icon Akihiro Matsuura
Arrow right icon
Can$34.98 Can$49.99
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6 (5 Ratings)
eBook Nov 2015 254 pages 1st Edition
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial
eBook
Can$34.98 Can$49.99
Paperback
Can$61.99
Subscription
Free Trial

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Table of content icon View table of contents Preview book icon Preview Book

Cocos2d-x cookbook

Chapter 1. Getting Started with Cocos2d-x

In this chapter, we're going to install Cocos2d-x and set up the development environment. The following topics will be covered in this chapter:

  • Setting up our Android environment
  • Installing Cocos2d-x
  • Using the Cocos command
  • Building the project using Xcode
  • Building the project using Eclipse
  • Implementing multi-resolution support
  • Preparing your original game

Introduction

Cocos2d-x is an open source, cross-platform game engine, which is free and mature. It can publish games for mobile devices and desktops, including iPhone, iPad, Android, Kindle, Windows, and Mac. Cocos2d-x is written in C++, so it can build on any platform. Cocos2d-x is open source written in C++, so we can feel free to read the game framework. Cocos2d-x is not a black box, and this proves to be a big advantage for us when we use it. Cocos2d-x version 3, which supports C++11, was only recently released. It also supports 3D and has an improved rendering performance. This book focuses on using version 3.4, which is the latest version of Cocos2d-x that was available at the time of writing this book. This book also focuses on iOS and Android development, and we'll be using Mac because we need it to develop iOS applications. This chapter explains how to set up Cocos2d-x.

Setting up our Android Environment

Getting ready

We begin by setting up our Android environment. If you wish to build only on iOS, you can skip this step. To follow this recipe, you will need some files.

The following list provides the prerequisites that need to be downloaded to set up Android:

  • Eclipse ADT (Android Developer Tools) with the Android SDK:

    https://dl.google.com/android/adt/adt-bundle-mac-x86_64-20140702.zip

    Eclipse ADT includes the Android SDK and Eclipse IDE. This is the Android development tool that is used to develop Android applications. Android Studio is an Android development IDE, but it is not supported to build NDK. The official site states that a version of Android Studio that supports NDK will be released soon. That's why we use Eclipse in this book.

  • Android NDK (Native Development Kit):

    https://dl.google.com/android/ndk/android-ndk-r10c-darwin-x86_64.bin

    The NDK is required to build an Android application. You have to use NDK r10c. This is because compiling and linking errors may occur when using NDK r9 or an earlier version.

  • Apache ANT:

    You can download Apache ANT from http://ant.apache.org/bindownload.cgi

    This is a java library that aids in building software. At the time of writing this book, version 1.9.4 was the latest stable version available.

How to do it...

  1. You begin by installing Eclipse ADT with the Android SDK, and then continue to unzip the zip file to any working directory you are aware of. I recommend that you unzip it to the Documents folder (~/adt-bundle-mac-x86_64-20140702). ADT includes Android SDK and Eclipse. The SDK and Eclipse folders are located under the ADT folder. We call the SDK folder path that is located under the ADT folder ANDROID_SDK_ROOT. You have to remember it because you will use it the next recipe. Now, you can launch Eclipse from ~/adt-bundle-mac-x86_64-20140702/eclipse/Eclipse.app.
  2. The next step is to update Android SDK:
    • Open Eclipse from the eclipse folder located in ADT.
    • Go to Window | Android SDK Manager.
    • After opening Android SDK Manager, check Tools and the latest Android SDK (API21), Android 2.3.3(API10), and any other SDK if necessary, as shown in the following screenshot:
      How to do it...
    • Click on Install packages....
    • Select each license and click on Accept, as shown in the following screenshot:
      How to do it...
    • After you accept all licenses, you will see that the Install button is enabled. Click on it.
    • You have to wait for a long time to update and install the SDKs.
  3. Installing NDK:

    Open the terminal window and change the directory to the path from which you downloaded the package. Change the permission on the downloaded package and execute the package. For example:

    $ chmod 700 android-ndk-r10c-darwin-x86_64.bin
    $ ./android-ndk-r10c-darwin-x86_64.bin
    

    Finally, you move the NDK folder to the Documents folder. We call the installation path for NDK NDK_ROOT. NDK_ROOT is the address of the folder that contains the files, it helps the Cocos2dx engine to locate the native files of Android. You have to remember NDK_ROOT because you will use it in the next recipe.

  4. Installing Apache ANT:

    Unzip the file to the Documents folder. That's all. We call ANT_ROOT the installation path for ANT. You have to remember ANT_ROOT, as we'll be using it in the next recipe.

  5. Installing Java:

    By entering the following command in the terminal, you can automatically install Java (if you haven't installed it earlier):

    $ java --version
    

    After installing it, you can check that it was successfully installed by entering the command again.

How it works...

Let's take a look at what we did throughout the recipe:

  • Installing Eclipse: You can use Eclipse as an editor for Cocos2d-x
  • Installing ADT: You can develop Android applications on Eclipse
  • Installing NDK: You can build a C++ source code for Java
  • Installing ANT: You can use command line tools for Cocos2d-x

Now you've finished setting up the Android development environment. At this point, you know how to install them and their path. In the next recipe, you will use them to build and execute Android applications. This will be very useful when you want to debug Android applications.

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.

Using the Cocos command

The next step is using the cocos command. It is a cross-platform tool with which you can create a new project, build it, run it, and deploy it. The cocos command works for all Cocos2d-x supported platforms and you don't need to use an IDE if you don't want to. In this recipe, we take a look at this command and explain how to use it.

How to do it...

  1. You can use the cocos command help by executing it with the --help parameter, as follows:
    $ cocos --help
    
  2. We then move on to generating our new project:

    First, we create a new Cocos2d-x project with the cocos new command, as shown here:

    $ cocos new MyGame -p com.example.mygame -l cpp -d ~/Documents/
    

    The result of this command is shown the following screenshot:

    How to do it...

    Behind the new parameter is the project name. The other parameters that are mentioned denote the following:

    • MyGame is the name of your project.
    • -p is the package name for Android. This is the application ID in the Google Play store. So, you should use the reverse domain name as the unique name.
    • -l is the programming language used for the project. You should use cpp because we will use C++ in this book.
    • -d is the location in which to generate the new project. This time, we generate it in the user's documents directory.

    You can look up these variables using the following command:

    $ cocos new —help
    

    Congratulations, you can generate your new project. The next step is to build and run using the cocos command.

  3. Compiling the project:

    If you want to build and run for iOS, you need to execute the following command:

    $ cocos run -s ~/Documents/MyGame -p ios
    

    The parameters that are mentioned are explained as follows:

    • -s is the directory of the project. This could be an absolute path or a relative path.
    • -p denotes which platform to run on. If you want to run on Android you use -p android. The available options are IOS, Android, Win32, Mac, and Linux.
    • You can run cocos run –help for more detailed information.

    The result of this command is shown in the following screenshot:

    How to do it...
  4. You can now build and run iOS applications on cocos2d-x. However, you have to wait for a long time if this is your first time building an iOS application. It takes a long time to build a Cocos2d-x library, depending on if it was a clean build or a first build.
    How to do it...

How it works...

The cocos command can create a new project and build it. You should use the cocos command if you want to create a new project. Of course, you can build using Xcode or Eclipse. You can easily develop and debug using these tools.

There's more...

The cocos run command has other parameters. They are the following:

  • --portrait will set the project as a portrait. This command has no argument.
  • --ios-bundleid will set the bundle ID for the iOS project. However, it is not difficult to set it later.

The cocos command also includes some other commands, which are as follows:

  • The compile command: This command is used to build a project. The following patterns are useful parameters. You can see all parameters and options if you execute the cocos compile [–h] command:
    cocos compile [-h] [-s SRC_DIR] [-q] [-p PLATFORM] [-m MODE]
    
  • The deploy command: This command only takes effect when the target platform is Android. It will re-install the specified project to the android device or simulator:
    cocos deploy [-h] [-s SRC_DIR] [-q] [-p PLATFORM] [-m MODE]
    

    Tip

    The run command continues to compile and deploy commands.

Building the project using Xcode

Getting ready

Before building the project using Xcode, you require Xcode with an iOS developer account to test it on a physical device. However, you can also test it on an iOS simulator. If you did not install Xcode, you can get it from the Mac App Store. Once you have installed it, get it activated.

How to do it...

  1. Open your project from Xcode:

    You can open your project by double-clicking on the file placed at: ~/Documents/MyGame/proj.ios_mac/MyGame.xcodeproj:

    How to do it...
  2. Build and Run using Xcode:

    You should select an iOS simulator or real device on which you want to run your project.

How it works...

If this is your first time building, it will take a long time but continue to build with confidence as it's the first time. You can develop your game faster if you develop and debug it using Xcode rather than Eclipse.

Building the project using Eclipse

Getting ready

You must finish the first recipe before you begin this step. If you have not finished it yet, you will need to install Eclipse.

How to do it...

  1. Setting up NDK_ROOT:
    • Open the preference of Eclipse
    • Open C++ | Build | Environment
      How to do it...
  2. Click on Add and set the new variable, the name is NDK_ROOT, and the value is NDK_ROOT path:
    How to do it...
  3. Importing your project into Eclipse:
    • Open the file and click on Import
    • Go to Android | Existing Android Code into Workspace
    • Click on Next
    How to do it...
  4. Import the project into Eclipse at ~/Documents/MyGame/proj.android:
    How to do it...
  5. Importing the Cocos2d-x library into Eclipse:
    • Perform the same steps from Step 3 to Step 4.
    • Import the project cocos2d lib at ~/Documents/MyGame/cocos2d/cocos/platform/android/java, using the following command:
      importing cocos2d lib
      
    How to do it...
  6. Build and Run:
    • Click on the Run icon
    • The first time, Eclipse will ask you to select a way to run your application. Select Android Application and click on OK, as shown in the following screenshot:
      How to do it...
    • If you connected to the Android device on your Mac, you can run your game on your real device or an emulator. The following screenshot shows that it is running on Nexus5:
      How to do it...
  7. If you added cpp files into your project, you have to modify the Android.mk file at ~/Documents/MyGame/proj.android/jni/Android.mk. This file is needed to build the NDK. This fix is required to add files.
  8. The original Android.mk would look as follows:
    LOCAL_SRC_FILES := hellocpp/main.cpp \
                       ../../Classes/AppDelegate.cpp \
                       ../../Classes/HelloWorldScene.cpp
  9. If you added the TitleScene.cpp file, you have to modify it as shown in the following code:
    LOCAL_SRC_FILES := hellocpp/main.cpp \
                       ../../Classes/AppDelegate.cpp \
                       ../../Classes/HelloWorldScene.cpp \
                       ../../Classes/TitleScene.cpp 

The preceding example shows an instance of when you add the TitleScene.cpp file. However, if you are also adding other files, you need to add all the added files.

How it works...

You get lots of errors when importing your project into Eclipse, but don't panic. After importing the Cocos2d-x library, errors soon disappear. This allows us to set the path of the NDK, Eclipse could compile C++. After you have modified the C++ codes, run your project in Eclipse. Eclipse automatically compiles C++ codes, Java codes, and then runs.

It is a tedious task to fix Android.mk again to add the C++ files. The following code is the original Android.mk:

LOCAL_SRC_FILES := hellocpp/main.cpp \
                   ../../Classes/AppDelegate.cpp \
                   ../../Classes/HelloWorldScene.cpp

LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../Classes

The following code is the customized Android.mk that adds C++ files automatically:

CPP_FILES := $(shell find $(LOCAL_PATH)/../../Classes -name *.cpp)
LOCAL_SRC_FILES := hellocpp/main.cpp
LOCAL_SRC_FILES += $(CPP_FILES:$(LOCAL_PATH)/%=%)

LOCAL_C_INCLUDES := $(shell find $(LOCAL_PATH)/../../Classes -type d)

The first line of the code gets C++ files to the Classes directory into the CPP_FILES variable. The second and third lines add C++ files into the LOCAL_C_INCLUDES variable. By doing so, C++ files will be automatically compiled in the NDK. If you need to compile a file other than the extension .cpp file, you will need to add it manually.

There's more...

If you want to manually build C++ in NDK, you can use the following command:

$ ./build_native.py

This script is located in ~/Documents/MyGame/proj.android . It uses ANDROID_SDK_ROOT and NDK_ROOT in it. If you want to see its options, run ./build_native.py –help.

Implementing multi-resolution support

You may notice a difference in screen appearance on different devices. In some previous recipes, there is an iOS's screenshot and a Nexus 5's screenshot. It shows different image sizes. This image is HelloWorld.png located at MyGame/Resources. It is 480 x 320 pixels. In this recipe, we explain how to maintain the same size regardless of screen size.

How to do it…

Open AppDelegate.cpp through Xcode, and modify the AppDelegate::applicationDidFinishLaunching() method by adding the code after the director->setAnimationInterval(1.0/60.0); line, as shown in the following code:

director->setAnimationInterval(1.0 / 60);
glview->setDesignResolutionSize(640, 960, ResolutionPolicy::NO_BORDER);

In this book, we design the game with a screen size of iPhone's 3.5 inch screen. So, we set this screen size to the design resolution size by using the setDesignResolutionSize method. The last parameter is resolution policy. The following screenshot is the Nexus 5's screenshot after implementing multi-resolution:

How to do it…

The following screenshot is the iPhone 5 simulator's screenshot. You now know that both screenshots have the same appearance:

How to do it…

How it works…

The resolution policy has EXACT_FIT, NO_BORDER, SHOW_ALL, FIXED_HEIGHT, and FIXED_WIDTH. These are explained as follows:

  • EXACT_FIT: The entire application is visible in the specified area without trying to preserve the original aspect ratio.
  • NO_BORDER: The entire application fills the specified area, without distortion but possibly with some cropping, while maintaining the original aspect ratio of the application.
  • SHOW_ALL: The entire application is visible in the specified area without distortion, while maintaining the internal the aspect ratio of the application. Borders can appear on two sides of the application.
  • FIXED_HEIGHT: The application takes the height of the design resolution size and modifies the width of the internal canvas so that it fits the aspect ratio of the device. No distortion will occur, however, you must make sure your application works on different aspect ratios.
  • FIXED_WIDTH: The application takes the width of the design resolution size and modifies the height of the internal canvas so that it fits the aspect ratio of the device. No distortion will occur, however, you must make sure your application works on different aspect ratios.

By implementing multi-resolution, regardless of screen size, you will maintain the image on the screen.

Preparing your original game

In the next chapter, we will start the original game. You know there are a lot of comments and codes in HelloWorldScene.cpp and the HelloWorldScene.h file. That's why we will remove unnecessary codes in the template project and get started with the original game right away.

How to do it…

  1. Open HelloWorldScene.h and remove the menuCloseCallback method and unnecessary comments. Now HelloWorldScene.h should look like the following code:
     #ifndef __HELLOWORLD_SCENE_H__
       #define __HELLOWORLD_SCENE_H__
       #include "cocos2d.h" 
    
       class HelloWorld : public cocos2d::Layer
       { 
    public:
        static cocos2d::Scene* createScene();
        virtual bool init();
        CREATE_FUNC(HelloWorld);
    };
    #endif // __HELLOWORLD_SCENE_H__
  2. The next step is to open HelloWorldScene.cpp and remove unnecessary comments, codes, and methods. Now HelloWorldScene.cpp should look like the following code:
    #include "HelloWorldScene.h"
    USING_NS_CC; 
    Scene* HelloWorld::createScene()
    {
        auto scene = Scene::create();
        auto layer = HelloWorld::create();
        scene->addChild(layer);
        return scene;
    } 
    bool HelloWorld::init()
    {
        if ( !Layer::init() )
        {
            return false;
        }
        return true;
    }
  3. The next step is to remove unnecessary images in resources. Remove CloseNormal.png, CloseSelected.png and HelloWorld.png from the Resources folder in Xcode:
    How to do it…
  4. Finally, if you are developing only iOS and Android applications, you don't need files for other platforms such as Linux, Windows, and Windows Phone. You should remove these files.

    Before removing platform files, it should look like the following screenshot:

    How to do it…

    After removing platform files, it should look like the following screenshot:

    How to do it…

How it works…

With this recipe, you can get the simplest project ready before removing unnecessary comments, codes, and methods. Removing unnecessary platform codes and resources is important for reducing the size of your application. If you start building your original game from scratch, you will need to follow this recipe or chances are, you may get a black screen if you build and run this project. In the next chapter, you can start coding within this simple project.

Left arrow icon Right arrow icon

Description

Cocos2d-x is a suite of open source, cross-platform game-development tools used by thousands of developers all over the world. Cocos2d-x is a game framework written in C++, with a thin platform-dependent layer. Completely written in C++, the core engine has the smallest footprint and the fastest speed of any other game engine, and is optimized to be run on all kinds of devices. You will begin with the initial setup and installation of Cocos2d before moving on to the fundamentals needed to create a new project. You will then explore and create the sprites, animations, and actions that you will include in the game. Next you will look at strings and create labels, including a label with True Type Font (TTF) font support. Later, you will learn about layer and scene creation and transition. Then you will create the GUI parts essential for a game, such as buttons and switches. After that, you will breathe life into the game with background music and sound effects using the all new Cocos2d-x audio engine. You will then discover how to manage resource files and implement processes that depend on the operating system. Finally, you will polish your game with physics such as gravity and elevation, learn about tools that will help you make games more robust and stable, and get to know best practices to improve the game you have developed.

Who is this book for?

If you are a game developer and want to learn more about cross-platform game development in Cocos2d-x, then this book is for you. Knowledge of C++, Xcode, Eclipse, and how to use commands in the terminal are prerequisites for this book.

What you will learn

  • Install and set up Cocos2dx for your development environment
  • Build, test, and release game applications for iOS and Android
  • Develop your games for multiple platforms
  • Customize Cocos2dx for your games
  • Use a physical engine in your games
  • Save and load text, JSON, XML, or other formats
  • Explore the brand new features of Cocos2dx

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Nov 03, 2015
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783284764
Languages :
Tools :

What do you get with eBook?

Product feature icon Instant access to your Digital eBook purchase
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Billing Address

Product Details

Publication date : Nov 03, 2015
Length: 254 pages
Edition : 1st
Language : English
ISBN-13 : 9781783284764
Languages :
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just Can$6 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total Can$ 193.97
Cocos2d-x cookbook
Can$61.99
Cocos2d-X Game Development Blueprints
Can$69.99
Cocos2d-x by example (update)
Can$61.99
Total Can$ 193.97 Stars icon

Table of Contents

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

Customer reviews

Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.6
(5 Ratings)
5 star 60%
4 star 40%
3 star 0%
2 star 0%
1 star 0%
Kenjis Jan 23, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Cocos2d-x ver.3 での開発について基本から学べて、物理エンジン、加速度センサー、sqlite、http通信など実際のゲームに欠かせない実践的な内容についても分かり易く説明されています。より実践的な一例として、スプライトシート、zipファイル、sqliteファイルの暗号化などについても記載されています。英語が得意でなくても、文章構成がシンプルで説明自体も長々しくなく簡潔で読み易かったです。トピックごとに "Getting ready(準備)"、"How to do it ...(どうやってコード書くか)"、"How it works ...(書いたコードで何が起きるのか) "、"There's more...(さらに詳しく)" といった具合に順序立てており、コード暗記というよりは一般的なゲーム開発の手法も学べるように構成されていると思います。
Amazon Verified review Amazon
Hugo Dec 20, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book is simply awesome, for me is the best source to learn Cocos2d-x development in general and to make a top class game.Starting from the most basic concepts of the game engine, teaching how to use the engine features and how to go more deeply creating your own features based on your needs, using the base that Cocos2d-x have.This book is structured, you have good basis to make all kind of games, you will have one “how-to-do” to almost everything you may need to make your games, I liked because he teaches why he does and how, this way you don't have just a recipe, you have the basis to do much more.He shows how to use advanced techniques to make your games run in more professional style, using hardware communication on Android and iOS, this is very important and you don't find much information about, and he teaches from the basics, and you will feel comfortable to do what you need to do, using the specific platform capabilities.This book covers Physics, SQLite, Tiled Maps, Networking and much more, all the things you may need to make AAA cross-platform games.The author focus on iOS and Android, but you can use for all Cocos2d-x supported platforms, only have to know that if you want to develop to iOS, an Apple machine and an iPhone will be needed, but, all the examples for Android can be executed in all OS's, I use Linux and sometimes Windows, for the specific tools to facilitate your development, all that are mentioned have support for windows, and you may find alternatives, I have my own favorites.I recommend this book for everyone who want to make games, this is the best way to speed your project in a structured, organized and complete way.
Amazon Verified review Amazon
Sergio Martinez-Losa del Rincon Jan 04, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
There is something special in this book, indeed this book covers more than game development with cocos2d-x, it takes advantage of other topics like networking, HTTP request usage and SQLite integration to expand a simple development and turn you game into a great development.Besides this topics, there is a great chapter about physics with simple examples, this is one of the most difficult topic and this chapter makes it easy.The book cover many over themes like font management, UI designing, game UX and sprite sheet design. This book gives a lot of useful information to make a game from scratch to professional and the examples lets you develop a full game step by step.Cocos2d-x is available for several platforms and this books even tells hoe to configure all your tools and resources to build a game for iOS and Android.
Amazon Verified review Amazon
Perry Nally Jan 27, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Pretty great resource if you don't know much about Cocos2d-x. But if you already have knowledge in Cocos2d-x, like how to load sprites, physics, audio, and 3D models then only a part of this book may be useful. There is not much in the way of 3D, other than how to load a 3D model, which seems to have a spelling error in the first section it is described (using "3D modal" instead of "3D model"). Grammatically it needs a bit of work, but I understood everything that was being said.You can definitely use this as a reference or a getting started set of snippets, but all recipes would need to be modified to be implemented in a use-able game/app. That being said, you'll find the networking part very helpful. There does not seem to be enough clarity on the web on how to frame web service calls and process the data. This book helps with that. This is a critical part of securing external logins and other security items. It is a great book and I recommend it, but I cannot say its the most explanatory book on the subject, though it does cover all the relevant topics.Don't get me wrong, this book will help you go in the right direction and implement certain important standards, but you'll need to do your own leg work to figure out how to put all the pieces together.
Amazon Verified review Amazon
aseem gupta Jan 17, 2016
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Cocos2d-x current version: v3.9 - has more 3D APIs than 3.4 and also has refactored few 2D APIs. This book uses version 3.4 which is no less than perfect for creating 2D games and you can also use new SDK APIs with it without any trouble as at that time only cocos2d-x SDK APIs were introduced.---------TL;DR---------I expected real game usages would have been demonstrated which can be used directly or with some modifications or atleast would have given picture of where all it can be used. I guess, this is what cookbook stands for and not simply showing working of APIs.But I liked few chapters of this book for different reasons.----------CONS:----------1) Drawing shapes has been shown but real examples of it are not shown. I personally, think that merely showing working API is not a big deal.2) Progress Loader bar is show but timer is used to make progress and not actual resource loading where tough works goes in to implement to find out how many resources are loaded in the memory.3) Page view is shown which is good but this is normal API usage. Could have been better if had shown how page view is implemented to create cool menus like in Angry birds and some other games where on the screen, apart from the current page, some part of left and right page are also shown so that player knows that there is still something to be swiped left/right.---------PROS:---------1) Book is well organised. 'How it works’ part after every topic is good to have.2) Animations using plist is shown which is pretty convenient way if lots of animations are there in a game.3) ScrollView and Page View API usage is shown which you will miss in other places and which I remember I spent good time in implementing by myself. But it's merely API usage and you would have to think on how you can use this to adapt to your needs.4) VideoPlayer api is shown if someone wants to use movie player in his game. On different note, you can also show youtube videos from new SDK APIs.5) Physics chapter is explained nicely. But it uses inbuilt physics engine which is actually built upon chipmunk-not box2d but it’s as good as box2d for many games. I liked changing the gravity using accelerometer - I never thought I could it this way.6) People who are not aware of the tools to pack and use resources of your game in a professional way then you might like chapter 10 ‘’Improving Games with Extra features’.------------------------USPs of this book------------------------1) Chpt7: 'Working with Resource Files' is really good, particularly usage of sqlite for saving game data.2) Chpt11:'Taking Advantages’.a) Encrypting sqlite files for securing game data which is essential if you don't want players to change coins, etc they've earned in the game.b) Sprite sheet encryption is shown but very few games use it as it might need heavy processing before loading the game on mobiles. Anyways, example shows texture packer way for encrypting sprite sheets which is a paid feature.c) Observer pattern is shown which is actually the same as push notification section of the book Cocos2d-x beginner guide by example but with different example.(Just for a note, example in latter book is better example as it directly matches ready to use need. But it might not be the compulsory thing that you might want to add observer pattern, if you're a beginner, in your game because it’s a way how you design code and not something you can't avoid. Also, note, Push Notifications which I just talked about in 2nd book is not same as push notifications that we receive in our smartphones.)d) Http networking is shown which is almost same as cocos2d-x official programmer’s guide example. But this book gives a bit more explanation with a working example which might arouse curiosity in some readers. So, you might like it.e) Using native code(Objective C/Java usage with C++) which can be required by few games where developer wants some kind of processing based on which platform it is. Usage is shown but CCLOG is used which I don’t like in books as I don't find it as a good way to demonstrate a practical example.
Amazon Verified review Amazon