Cocos2d for iPhone 0.99 Beginner’s Guide Review
Book Summary
The book, Cocos2d for iPhone 0.99 Beginner's Guide by Pablo Ruiz, is an introduction to game development using the cocos2d for iPhone framework (http://www.cocos2d-iphone.org/). cocos2d for iPhone is an open source game development framework for Objective-C based on the cocos2d framework originally written in Python. As the 2d in the title suggests, it is really geared towards 2D games, although there can be 3D effects. The framework is free to use even in commercial products and is actively maintained with a large community. The framework has even branched out towards iPad and Mac OS X development.
The book presents the cocos2d framework by walking the reader through building three different games: Coloured Stones (Bejeweled-like game), AerialGun (vertical shooter), and Totem Balance (physics puzzler). These games are presented through a series of steps, starting with installing cocos2d on through developing nearly complete games. Each of the steps are fairly small and the author doesn't present too many concepts in each step. However each step provides a concrete result so that the reader can quickly see the results of what was just added to the code. For example, one of the first steps in AerialGun simply displays the main player sprite. Then it quickly moves on to adding the enemy sprites and making them move and shoot. From there, steps are added to handle the accelerometer to steer the player sprite, shoot bullets from the player sprite, and handle collisions between sprites.
While none of these games are overly complex - there are probably hundreds in the app store like them - these games do hit the main concepts of cocos2d as well as provide an introduction to game development concepts. There are topics on touch/accelerometer handling, sprites, collisions, animations, scoreboards/huds, tile maps, menus, transitions, particles and physics. The author even adds the little extra "flash" to the games, especially in the Coloured Stones example. These include animating the appearance and disappearance of the stones, animating the background on major events, and animating score for the removed stones. While this does extend out the example a bit, it is nice that the author shows that adding effects like these are really simple to do in cocos2d yet add tremendous value visually.
In addition to just describing cocos2d, the author adds some game development insights along the way especially with respect to game performance such as sprite reuse, tiling backgrounds, avoiding large images, image and sound loading, and tips on using the physics engine. He also provides a brief tutorial on several common game development tools used to create tile maps and particle effects. At the end there is even a chapter on integrating OpenFeint, one of the more popular social networks for games.
My Thoughts
Full disclosure: I was sent a copy of this book to review by the publisher. However, this fact has no bearing on my review.
This book is geared towards beginners in cocos2d and to some extent game development. The author assumes the reader has basic knowledge of iPhone development and Objective-C. While a reader can start iPhone game development with this book, not having any other background in iPhone development will be an issue. If keywords like @selector, retain, and autorelease are not familiar to the reader, a good Objective-C and/or iPhone development book will be handy to have nearby.
In addition, while it touches on some concepts of game development as its primary purpose is cocos2d and so it does not provide information on items like artificial intelligence, multi-player, networking, and general game design. Another book or online resource is needed for these and other advanced topics.
As mentioned in the book summary above, the author does provide that extra little bit of detail on some of the examples to add some polish. However, I wish the book editing went through the same level of detail. There are numerous errors throughout, both in the code examples and the surrounding text, that detract from the overall book. These may confuse the reader, especially if they are truly beginners.
The other issue, which is common with all technical books detailing an active framework, is keeping up with the latest version of the cocos2d library (currently version 0.99.5, but 1.0 is on its way). For example, the book mentions the PVR textures can only be used for 2 or 4 bit textures, but the 0.99.5 release allows you to pack any type of texture in the PVR format for image loading speed gains.
As an experienced iPhone developer, with some previous exposure to cocos2d in the past, I found the book to be a good refresher on cocos2d basics. I did find the book really useful in its explanation of the more advanced topics like particle effects, node actions, and the Chipmunk physics engine. There were times I wish the book went into more details, but then again this book is a "beginner's guide" so that is expected.
Overall, I think this book is a good starting point for someone who wants to come up to speed on cocos2d. While a lot of information is available on the web, having all the information in one spot and presented in a consistent manner is very useful. That being said, unless the book is updated for the newer releases, the book will need to be used in conjunction with the latest API documentation on the website.