Book Review: Learning Cocos2D

When I was making the transition into iOS development from Internet engineering, I grabbed two 500 page iPhone app development books, read and worked the examples over a Christmas vacation, coded nights and weekends for three months and produced an app that Apple highlighted as New and Noteworthy, the Dog Park Finder. So, now when I decided to make the leap from iOS development to iOS game development 18 months later, I wanted to grab a great intro book and go from there.

First I had to determine the tools I would use, and landed upon Cocos2D (this isn't a game platform review, so I am not going into the pros/cons of Cocos2D or other platforms, that is a different post). Following that decision, I grabbed Learning Cocos2D by Rod Strougo and Ray Wenderlich. The other obvious choice was Learn iPhone and iPad Cocos2D Game Development. Honestly, I came across Learning Cocos2D first, which is why I bought it.

Learning Cocos2D is a great book to use as an on-ramp to the Cocos2D platform, as well a giving good best practice insight into general game development, and design pattern to follow. If are a long term game developer, well versed in texture map optimization, OpenGL programming or physics modeling, then you probably should just read the Cocos2D API documentation. But if not, Learning Cocos2D is a hands on book for getting up to speed quickly (if you are altogether new to Objective-C and iOS development, the a read through an basic iPhone programming book before working through this book).

The book uses working example of building a Space Viking game (free at the app store). Through the examples you will be shown how to make a splash screen, menu pages (including credits and options pages), how to move and animate sprites, spawn enemies, scroll the landscape, create gravity puzzles and joy ride in a mine cart across an alien landscape. Among other things. All the while, Rod and Ray skillful introduce support tools and mix in programming best practices for optimizing memory and speed up the game.

Like many of books of this nature, all the sample code viewed in the book, is also available for download. It is a great help see and interact with an entire XCode project when a concept is eluding you. Also, the authors have given full permission to use the code in any manner to help accelerate your projects.

The book's 17 chapters are broken into five sections. Instead of highlights and review each chapter's content, I will do so at the section level.

The four chapters in the 'Getting Started' section give a steps the reader from a installing Cocos2D into XCode, to simple 'Hello World' program, to making your first game scene with a hero, a villain, some animations and basic collision detection. These chapters define the basic Cocos2D vocabulary of scenes, layers and sprites, along with batching sprites for performance, definition animation sequences in plists instead of in the code, and spells out some of the workflow and time saving API calls for handling sprite movements and scene updates.

The next short section involves chapters 5 and 6 where some decent amount of computer science concepts of class hierarchy, interfaces and other concepts are written along side instructions about sprite and layer affects, generating text labels, and other font usage. The authors also help guide you to a quick debugging layer for better testing of your games.

'From Level to Game', is the third section of the book. Chapter 7 deals with Cocos2D's menu items, which can be used to create dynamic menus, directing to new scenes for viewing credits, as well as creating options for defining game settings. Chapter 8 is dedicated to all things audio. Including different tools for importing sound and asynchronous loading of sound/music for a better user experience. Lastly Chapter 9 deals with larger levels than one screen can hold. Both scrolling, and parallax scrolling are covered as well as the efficient way to create and reuse time maps.

The most cerebral of sections, is 'Physics Engines' sections. I spent a little less time working the examples of the Physics chapters 10 through 13, but Rod and Ray extensively introduce both the Box2D and Chipmunk Physics engines. Starting a bit easy with gravity, mass and simple collisions to setting up a fully actuated Viking to throw and rag-doll around, these chapters lay a solid foundations for you to explore physics in the Cocos2D world on your own.

Lastly, a ragtag section is used to wrap up the basic particle system in Cocos, while giving pointers for toll in creating your own particle effects. A chapter is also dedicated to Game Center integration, including login/sign up, creating leader boards, setting achievements, and how to save updates when an Internet connection is not available. Besides the conclusion, the last chapter deals with general performance tips, debugging and profiling guides and some quick tips to loading your sprites faster.

Too sum up, Learning Cocos2D is not just a book on how to use Cocos2D, but really a how-to guide to making your first iOS Cocos2D game with good technical architecture, with many best practices and how-to's thrown in. At over 500 pages, it isn't a quick read, but I would recommend it to anyone looking for good book for iOS Cocos2D development

Before signing off, I thought I should also introduce myself, as this is my first post for My name is Greg Holsclaw, and I am the founder of Skejo Studios, a new iOS shop. We have already produced two apps for ourselves (one is the Dog Park Finderwith over 200K downloads), and two more for clients. Since completing a BS in computational mathematics, I have been creating websites and backend engineering for 7 years, and creating iOS apps for the last two years.

My hobbies sites and weekend work has blossomed enough that I recently was able to resign my engineering lead role at a successful internet startup to create Skejo Studios, and there is no looking back. Look for more posts at concerning the intersection of Drupal (a web CMS) and iOS apps, as well as development diaries for the games we are developing. Until next time. -Greg