Coco2d-x Cookbook

Front Cover
Packt Publishing, Oct 31, 2015 - Computers - 254 pages
Over 50 hands-on recipes to help you efficiently administer and maintain your games with Cocos2d-xAbout This Book- Build exciting games, apps, and other cross-platform GUI based interactive programs with Cocos2d-x- Explore the nitty-gritty of the latest Cocos2d-x on the block, version 3.6- A step-by-step guide that shows you the functionalities of Cocos2d-x followed by an explanation of how they workWho This Book Is ForIf 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 Cocos2d-x for your development environment- Build, test, and release game applications for iOS and Android- Develop your games for multiple platforms- Customize Cocos2d-x 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 Cocos2d-xIn DetailCocos2d-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.Style and approachThis book is an easy-to-follow guide with ample recipes to help you better understand Cocos2d-x.

What people are saying - Write a review

User Review - Flag as inappropriate

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
---------
APIs usages are shown but since it's a cookbook, I expected, real game usages should have been shown so that they can be directly used or with some modifications. This is what cookbook stands for and not simply showing working of APIs but their "real" application usage. But I liked some a few chapter 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
 

Other editions - View all

About the author (2015)

Akihiro Matsuura has five years of experience as a Cocos2d-x developer. He founded his own company called Syuhari, Inc. five years ago. He has more than 20 years of experience as a programmer. He has written three technical books in Japanese. He also authored Cocos2d-x Recipe Book, Shuwa System Co., Ltd , the first Cocos2d-x book in Japan, iPhone SDK Recipe Book , Shuwa System Co., Ltd, and Cocos2d-x Guide Book, Mynavi Corporation.7 years ago, iPhone3G was released in Japan. This was when he began to develop its software and ended up developing a lot of applications for iPhone. First, he developed them using Cocos2d for iPhone; however, he had to port to Android. So, he decided to use Cocos2d-x to develop cross-platform applications. At that time, Cocos2d-x was at version 1.0.Since then, he has developed a lot of applications using Cocos2d-x.

Bibliographic information