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
Free Learning
Arrow right icon
Cocos2d-x by example (update)
Cocos2d-x by example (update)

Cocos2d-x by example (update): Unleash your inner creativity with the popular Cocos2d-x framework and learn how to build great cross-platform 2D games with this Cocos2dx tutorial

eBook
£7.99 £29.99
Paperback
£36.99
Subscription
Free Trial
Renews at £16.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

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

Cocos2d-x by example (update)

Chapter 1. Installing Cocos2d-x

In this chapter, we'll get things up and running on your machine so you can get the most out of the examples in this book. 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, such as tools to build sprite sheets, particle effects, and bitmap fonts. Although these tools are optional, and you can still learn how to use sprite sheets, particles, and bitmap fonts just by following the examples given in this book, you might consider these tools for your own projects.

Things you will learn in this first chapter are as follows:

  • How to download Cocos2d-x
  • How to run your first multiplatform application
  • What the basic project looks like and how to find your way around it
  • How to use the test project as a major reference source

Downloading and installing Cocos2d-x

All the examples in this book were developed in a Mac using Xcode and/or Eclipse. The example in the final chapter uses Cocos2d-x own IDE for scripting. Although you can use Cocos2d-x to develop your games for other platforms using different systems, the examples were built in a Mac and deployed to both iOS and Android.

Xcode is free and can be downloaded from the Mac App store (https://developer.apple.com/xcode/index.php), but in order to test your code on an iOS device and publish your games, you will need a developer account with Apple, which will cost you $99 a year. You can find more information on their website: https://developer.apple.com/.

For Android deployment, I recommend that you get the Eclipse and ADT bundle from Google, which you can find at http://developer.android.com/sdk/installing/installing-adt.html. You will be able to test your games in an Android device for free.

So, assuming you have an Internet connection, let's begin!

Time for action – downloading, downloading, downloading

We start by downloading the necessary SDKs, NDKs, and general bits and bobs:

  1. Go to http://www.cocos2d-x.org/download and download the latest stable version of Cocos2d-x. For this book, I'll be using version Cocos2d-x-3.4.
  2. Uncompress the files somewhere in your machine you can remember later. I recommend that you add all the files we're going to download now to the same folder.
  3. Go ahead and download the Code IDE as well. We'll be using this in the last chapter in this book.
  4. Then, go to http://developer.android.com/sdk/installing/installing-adt.html and download the Eclipse ADT plugin (if you don't have Eclipse or the Android SDK installed, download them at https://eclipse.org/downloads/ and http://developer.android.com/sdk/installing/index.html?pkg=tools, respectively).

    Note

    If you have any problems installing the ADT plugin, you will find complete instructions at http://developer.android.com/sdk/installing/installing-adt.html.

  5. Now, for Apache Ant, go to http://ant.apache.org/bindownload.cgi and look for the links to the compressed files, and download the .zip one.
  6. Lastly, go to https://developer.android.com/tools/sdk/ndk/index.html and download the latest version of the NDK for your target system. Follow the installation instructions on this same page on how to extract the files as some systems will not allow these to be self-extractable. A word of warning: you must use a version of the NDK above r8e with Cocos2d-x 3.x.

What just happened?

You have successfully downloaded everything you'll need to set up Cocos2d-x in your machine and start development. If you are using a Mac, you will probably need to change your security settings in System Preferences to allow Eclipse to run. Also, go ahead and open the Android SDK Manager inside Eclipse by going to the Window-Android SDK Manager menu, and install the packages for at least Version 2.3.3 and then anything above that you might wish to target.

Also, make sure you have Python installed in your machine. Inside Terminal or command prompt, just type the word python and hit enter. If you don't have it installed, visit https://www.python.org/ and follow the instructions there.

So by the end of this step you should have Cocos2d-x, CocosIDE, the Android SDK the NDK, and Apache Ant all extracted inside a folder.

Now let's install Cocos2d-x.

Time for action – installing Cocos2d-x

Open Terminal or command prompt and navigate to the Cocos2d-x extracted folder:

  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.4
  2. Next, type python setup.py.
  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. So for the NDK I get:
    /Applications/Dev/android-ndk-r10c
  4. Next, it's the path for the SDK. Once again, I drag the folder that I have stored inside Eclipse's folder:
    /Applications/eclipse/sdk
  5. Next, it's the path to ANT. If you have it properly installed on your machine, the path will be something like usr/local/bin and the setup script will find it for you. Otherwise, you can use the one you downloaded and extracted. Just point to the bin folder inside it:
    /Applications/Dev/apache-ant-1.9.4/bin
  6. 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.

What just happened?

You now have Cocos2d-x installed on your machine and you're ready to go. Time to create our first project!

Hello-x World-x

Let's create that old chestnut in computer programming: the hello world example.

Time for action – creating an application

Open Terminal again and follow these easy steps:

  1. You should have the path to the Cocos2d-x console already added to your system. You can test this by using the cocos command inside Terminal. In order to create a new project called HelloWorld, using C++ as its primary language and save it on your desktop, you need to run the following command, replacing YOUR_BUNDLE_INDETIFIER with a package name of your choice, and replacing PATH_TO_YOUR_PROJECT with the path to wherever you wish to save your project:
    cocos new HelloWorld -p YOUR_BUNDLE_IDENTIFIER -l cpp -d PATH_TO_YOUR_PROJECT
    
  2. As an example, in my machine this is the line I typed:
    cocos new HelloWorld -p com.rengelbert.HelloWorld -l cpp -d /Users/rengelbert/Desktop/HelloWorld
    

    And hit Enter. If you choose not to give a directory parameter (-d), the Cocos console will save the project inside the Cocos2d-x folder.

  3. Now you can go to your desktop, or wherever you chose to save your project, and navigate to the folder proj.ios_mac inside the HelloWorld project. Inside that folder you'll find the Xcode project file. Once you open the project inside Xcode, you can click the Run button and you're done.
    Time for action – creating an application

Note

When you run a cocos2d-x application in Xcode, it is quite common for the program to post some warnings regarding your code, or most likely, the frameworks. These will mostly reference deprecated methods or statements that do not precisely follow more recent and stricter rules of the current SDK. But that's okay. These warnings, though certainly annoying, can be ignored.

What just happened?

You created your first Cocos2d-x application. The parameters used on the command line are:

  • -p for package or bundle identifier
  • -l for language, and here, you have the option cpp, lua, or JavaScript

Now let's run this app in Android.

Tip

Downloading the example code

You can download the example code files from your account at http://www.packtpub.com for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you.

Time for action – deploying to Android

We're going to open the project inside Eclipse:

  1. Open Eclipse.
  2. We need to fix the path to the NDK; this step may be optional in your system, and in any case, it must be done only once. Inside Eclipse, go to Eclipse-Preferences, then inside the C/C++ option select Build-Environment.
  3. You need to add the NDK path and it must be called NDK_ROOT. In order to do this, you must click Add…, and use NDK_ROOT as the name and then click inside the Value field to make sure the mouse cursor is active inside it, and then drag the NDK folder you downloaded inside the field. On my machine the result looked like this:
    Time for action – deploying to Android
  4. Click Apply. It might be good to restart Eclipse. (If you do not see the C/C++ option in Preferences, it means you do not have the CDT plugins installed. Look for complete instructions at http://www.eclipse.org/cdt/ on how to install them.)
  5. Now we're ready to bring our project inside Eclipse. Select File | Import….
  6. In the dialog box, select the Android option, and then select the Existing Android Code Into Workspace option and click Next:
    Time for action – deploying to Android
  7. Click on the Browse button and navigate to the HelloWorld project, and select the proj.android folder inside it and hit Next.
  8. You should see the project compiling. The entire framework library will be compiled and so will the classes used in the base template.
  9. Sadly, with Version 3.4 of the framework, we have an extra step here. It was gone in Version 3.3, but now it's back. You must import the project's referenced Cocos2d-x library into Eclipse's package explorer. Repeat step 8, but instead of selecting the proj.android folder, select cocos2d/cocos/platform/android/java, and hit Next.
  10. This will select a library called libcocos2dx; click on Finish.
  11. Once that's done, it might be good to run a build just in case your project failed to generate the correct resource files. So, navigate to Project | Build All.
  12. Now, connect your Android device and make sure Eclipse has recognized it. You might need to turn on Development options in your device, or restart your device while connected to your computer and with Eclipse running.
  13. Right-click on your project folder and select Run As | Android Application.

What just happened?

You ran your first Cocos2d-x application in Android. Don't bother with the simulator for your Android builds; it's a waste of time. If you don't have a device handy, consider investing in one.

Alternatively, you could open your project's root folder inside Terminal (or command prompt) and use the Cocos2d-x console compile command:

cocos compile -p android

The people behind Cocos2d-x have announced they will get rid of the build Python script in the future versions of the framework, so it's good to be prepared and know how to go without it.

While working with Eclipse, you might soon be faced with the dreaded java.lang.NullPointerException error. This might be related to conflicts in the ADT, CDT or NDK!

Note

When you're faced with this error you have no option other than reinstall whatever Eclipse points to as the culprit. This might happen after an update, or if for some reason you have installed another framework that uses a path to the NDK or ADT. If the error is tied to a particular project or library, just remove all projects from the package explorer in Eclipse and reimport them.

Now let's go over the sample application and its files.

The folder structure

First you have the Classes folder; this will contain the classes for your application, and are written entirely in C++. Below that is the Resources folder, where you find the images, fonts, and any kind of media used by the application.

The ios folder has the necessary underlying connection between your app and iOS. For other platforms, you will have their necessary linkage files in separate folders targeting their respective platform.

It is important to maintain this file structure. So your classes will go into the Classes folder and all your images, sound files, fonts, level data should be placed in the Resources folder.

The folder structure

Now let's go over the main classes of the basic application.

The iOS linkage classes

AppController and RootViewController are responsible to setting up OpenGL in iOS as well as telling the underlying operating system that your application is about to say Hello... To the World.

These classes are written with a mix of Objective-C and C++, as all the nice brackets and the .mm extension show. You will change very little, if anything, on these classes; and again that will reflect in changes to the way iOS handles your application. So other targets would require the same instructions or none at all, depending on the target.

In AppController for instance, I could add support for multitouch. And in RootViewController, I could limit the screen orientations supported by my application, for instance.

The AppDelegate class

This class marks the first time your C++ app will talk to the underlying OS. It attempts to map the main events mobile devices we want to dispatch and listen to. From here on, all your application will be written in C++ (unless you need something else for a specific target) and from this point on, you can add conditional code for different targets.

In AppDelegate, you should set up the Director object (it is the Cocos2d-x all powerful singleton manager object), to run your application just the way you want. You can:

  • Get rid of the application status information
  • Change the frame rate of your application
  • Tell Director where your high definition images are, and where your standard definition images are, as well as which to use
  • You can change the overall scale of your application, so it will best fit different screens
  • The AppDelegate class is also the best place to start any preloading process
  • And most importantly, it is here you tell the Director object what Scene to begin your application with

Here too, you will handle what happens to your application if the OS decides to kill it, push it aside, or hang it upside down to dry. All you need to do is place your logic inside the correct event handler: applicationDidEnterBackground or applicationWillEnterForeground.

The HelloWorldScene class

When you run the application, you get a screen with the words Hello World and a bunch of numbers in one corner; those are the display statistics you decided you wanted around in the AppDelegate class.

The actual screen is created by the oddly named HelloWorldScene class. It is a Layer class that creates its own scene (don't worry if you don't know what a Layer or a Scene class is; you will know soon).

When it initializes, HelloWorldScene puts a button on the screen that you can press to exit the application. The button is actually a Menu item part of a Menu object that only has one button, with two image states for the button, and one call back event when the said button is pressed.

The Menu object automatically handles touch events targeting its members, so you don't get to see any of that code floating about. Then, there is also the necessary Label object to show the Hello World message and the background image.

Who begets whom?

If have you never worked with either Cocos2d or Cocos2d-x before, the way the initial scene() method is instantiated may lead to dizziness. To recap, in AppDelegate you have:

auto scene = HelloWorld::createScene();
director->runWithScene(scene);

Director needs a Scene object to run, which you can think of as being your application, basically. Scene needs something to show, and in this case, a Layer object will do. Scene is then said to contain a Layer object.

Here a Scene object is created through a static method scene inside a Layer derived class. So the layer creates the scene, and the scene immediately adds the layer to itself. Huh? Relax. This incestuous-like instantiation will most likely happen only once, and you get nothing to do with it when it happens. So you can easily ignore all these funny goings-on and look the other way. I promise instantiations will be a much easier task after this first one.

Finding more reference material

Follow these steps to access one of the best sources for reference material on Cocos2d-x: its Test project.

Time for action – running the test samples

You can open the test project just like you would any other Xcode/Eclipse project:

  1. In Eclipse, you can import the test project from inside the Cocos2d-x folder you downloaded. You'll find it in tests/cpp-tests/proj.android.
  2. You can follow the same steps as before to build this project.
  3. In Xcode, you must open the tests project file that you'll find in the Cocos2d-x framework folder inside the build folder: build/cocos2d_tests.xcodeproj.
  4. Once the project is opened in Xcode, you must select the correct target next to the Run button as follows:
    Time for action – running the test samples
  5. In order to actually review the code inside the tests, you may navigate to tests/cpp-tests/Classes for the C++ tests or tests/lua-tests/src for the Lua tests. Better yet, if you have a program such as TextWrangler or an equivalent, you can open these entire directories inside a Disk Browser window and have all that information ready for referencing right at your desktop.

What just happened?

With the test samples, you can visualize most features in Cocos2d-x, what they do, as well as see some of the ways you can initialize and customize them.

I will refer to the code found in the tests quite often. As usual with programming, there is always a different way to accomplish the same task, so sometimes, after showing you one way, I'll refer to a different one that you can find (and by then easily understand) inside the Test classes.

The other tools

Now comes the part where you may need to spend a bit more money to get some extremely helpful tools (and do some extra bit of learning). In this book's examples, I use four of them:

  • A tool to help build sprite sheets: I'll use TexturePacker (http://www.codeandweb.com/texturepacker). There are other alternatives, such as Zwoptex (http://zwopple.com/zwoptex/), and they usually offer some features for free. Cocos2d-x now offers a free program called CocosStudio, which is somewhat similar to SpriteBuilder (previously CocosBuilder), and it offers ways to build sprite sheets, bitmap fonts, as well as a number of other goodies. At the time of writing this, the Windows version is somewhat superior to the Mac version, but they are free!
  • A tool to help build particle effects: I'll use Particle Designer (http://www.71squared.com/en/particledesigner). Depending on your operating system, you may find free tools online for this. Cocos2d-x comes bundled with some common particle effects that you can customize. But doing it blindly is a process I do not recommend. CocosStudio also allows you to create your own particle effects, but you may find its interface a bit daunting. It certainly requires its own book of tutorials!
  • A tool to help build bitmap fonts: I'll use Glyph Designer (http://www.71squared.com/en/glyphdesigner). But there are others: bmGlyph (which is not as expensive) and FontBuilder (which is free). It is not extremely hard to build a bitmap font—not nearly as hard as building a particle effect from scratch—but doing it once is enough to convince you to get one of these tools fast. Once again, you might give CocosStudio a go.
  • A tool to produce sound effects: No contest—sfxr for Windows or its Mac port cfxr. Both are free (http://www.drpetter.se/project_sfxr.html and http://thirdcog.eu/apps/cfxr, respectively).

Summary

You just learned how to install Cocos2d-x and create a basic application. You also learned enough of the structure of a basic Cocos2d-x application to start building your first game and you know how to deploy to both iOS and Android.

Keep the Test classes by your side as you go over the examples in this book and you will be a Cocos2d-x pro in no time!

But first, let's go over a few things regarding the framework and its native language.

Left arrow icon Right arrow icon

Description

If you are a game enthusiast who would like to develop and publish your own game ideas onto different app stores, this is the book for you. Some knowledge of C++ or Java is helpful but not necessary.

Who is this book for?

If you are a game enthusiast who would like to develop and publish your own game ideas onto different app stores, this is the book for you. Some knowledge of C++ or Java is helpful but not necessary.

What you will learn

  • Add timesaving and funlooking animations to your projects
  • Make your games look cooler with particle effects
  • Draw lines, circles, and other primitives on the screen
  • Create place holder sprites to quickly test your game ideas
  • Load external data into your games
  • Create projects and deploy them to iOS and Android
  • Prepare your game for a variety of screen sizes and resolutions
  • Use the CocosIDE and the Lua bindings to develop a game
Estimated delivery fee Deliver to Great Britain

Standard delivery 1 - 4 business days

£4.95

Premium delivery 1 - 4 business days

£7.95
(Includes tracking information)

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Mar 26, 2015
Length: 270 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288852
Tools :

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
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

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Great Britain

Standard delivery 1 - 4 business days

£4.95

Premium delivery 1 - 4 business days

£7.95
(Includes tracking information)

Product Details

Publication date : Mar 26, 2015
Length: 270 pages
Edition : 1st
Language : English
ISBN-13 : 9781785288852
Tools :

Packt Subscriptions

See our plans and pricing
Modal Close icon
£16.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
£169.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 £5 each
Feature tick icon Exclusive print discounts
£234.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 £5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total £ 115.97
Cocos2d-x cookbook
£36.99
Cocos2d-X Game Development Blueprints
£41.99
Cocos2d-x by example (update)
£36.99
Total £ 115.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Installing Cocos2d-x Chevron down icon Chevron up icon
2. You Plus C++ Plus Cocos2d-x Chevron down icon Chevron up icon
3. Your First Game – Air Hockey Chevron down icon Chevron up icon
4. Fun with Sprites – Sky Defense Chevron down icon Chevron up icon
5. On the Line – Rocket Through Chevron down icon Chevron up icon
6. Quick and Easy Sprite – Victorian Rush Hour Chevron down icon Chevron up icon
7. Adding the Looks – Victorian Rush Hour Chevron down icon Chevron up icon
8. Getting Physical – Box2D Chevron down icon Chevron up icon
9. On the Level – Eskimo Chevron down icon Chevron up icon
10. Introducing Lua! Chevron down icon Chevron up icon
A. Vector Calculations with Cocos2d-x Chevron down icon Chevron up icon
B. Pop Quiz Answers Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.9
(10 Ratings)
5 star 90%
4 star 10%
3 star 0%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




iPaul May 29, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Good introduction to Cocos2d-x, you need to an expert C++ programmer though. Also, because of the cocos2d-x history it will help if you at least have an idea of how Objective-C works.
Amazon Verified review Amazon
Hugo Mar 14, 2016
Full star icon Full star icon Full star icon Full star icon Full star icon 5
This book showed me that the code doesn't need to be too complicated to make a good and fun game. This version of Cocos2d-x is much more simple, if you never have tried in a game project before, you can be happy, is the right time to use it, this framework is mature, easy to understand, with a ton of resources to learn how it works, a big variety tools to do more in games and publish, but, if you already know how this framework works or if you are an experienced game developer, this book will show you how good and easy can be make really good games, the examples showed in this book are full of functionalities to make great games, you can translate your knowledge easy and fast, this framework support C++, JavaScript and Lua, the main focus on the book is C++ and show how easy is to do cool effects with the games, in the last example he makes a kind of super loved by mobile gamers in Lua. In the first chapters he teaches how to install and the basics of the framework, he also gives examples of tools that he use and are recommended to create spitesheets, particles, bitmap fonts and sound effects. If you already know C++ or another Object Oriented programming language, I think that the examples will show you the framework in a way that you will not be scared by the code, but if you've never used C++ or another Object Oriented programming language... this can be hard, but if you read again the book become easy, the examples showed are clear, you will take it. All the effort will be worth on you first game done, when you play something that you've made is one of the best things, all you need to start is on the book learn by examples mix some techniques and practice more and more, as soon as you can imagine your games will be good to show to your friends and make some money. I liked that the examples are simple, the code is explained block by block, game features that you and your users appreciate are showed and the examples explain how to work with physics Box2D and Chipmunk, particles, primitive draws, touch, collision and much more. This book is totally recommended if you want to learn or if you want to take advantage of the framework to make professional games.
Amazon Verified review Amazon
Jaime Sierra May 15, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Hello everyone, I'm Chilean and this book (2nd Edition) I looked forward, I am programmer Cocos2D ObjC is good but is only for iOS, but Cocos2D-x can be programmed for iOS and Android, which is great advantage . I tried for months to learn Cocos2D-x from many web, but it was not clear to me now to the book "Cocos2d-x by Example: Beginner's Guide - Second Edition" is updated and a true guide to set up my computer, and to design in C ++ as well as several aspects that are familiar to cocos2D ObjC. There is an excellent support service from the same publisher, respond quickly and well detailed.In short, excellent book.
Amazon Verified review Amazon
Christian S. Jun 10, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
The first version of this book was my second book I bought from Packt about 2 years ago. At that time I completed the book in a couple of months. Roger Engelbert did a splendid work in creating the examples and progressively increasing the difficulty to expose different concepts in each chapter. Considering how difficult it is to introduce C++ in an Objective-C and Java environment, they were carefully explained and easy to follow and the code just run as expected.This second edition does not disappoint. Besides updating all the libraries and frameworks to the most current versions (2 years in the mobile world is a lot!), the examples and explanations remain clear, carefully crafted.The mayor difference with the first edition is Chapter 10. It replaced the same chapter in the first edition (Eclipse setup in C++ for crossplatform builds) with the latest CocosIDE and Lua, which did not exist when the first version was released. This chapter feels like a cliffhanger waiting for a next book to show all the potential of Lua and the new CocosIDE.
Amazon Verified review Amazon
juan Oct 09, 2020
Full star icon Full star icon Full star icon Full star icon Full star icon 5
es muy bueno el libro
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact customercare@packt.com with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at customercare@packt.com using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on customercare@packt.com with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on customercare@packt.com within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on customercare@packt.com who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on customercare@packt.com within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela