on March 25, 2011
-- Book Summary --
This book is an introduction to game development using the cocos2d for iPhone framework. cocos2d for iPhone is an open source game development framework for and 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 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 which was originally posted on my blog.
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, 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.
on February 13, 2011
(Taken from full review at 'Under The Bridge' blog -- [...])
If you've completed a cocos2d game ... no, this is not a reference; you'll probably find some tidbits of value, but I wouldn't make it a high priority purchase. You probably guessed that from the `Beginner's Guide' name.
However, if you are a complete beginner to game programming ... no, the name notwithstanding, what this does cover will be over your head, and it doesn't cover things not related to cocos2d directly a beginner needs introduction to. We heartily recommend the iPhone Game Kit for you.
If you're a programmer new to the iPhone platform ... you'll struggle with the Objective-C, no doubt. Come back after you've done a program or two, got the Cocoa memory model down, and so forth.
So if none of those apply, presumably you know something about programming iOS already at the UIKit level and now you want to get into programming games, and you need a walkthrough of cocos2d design principles and the associated development toolchain? Excellent, you're the person this is actually appropriate for -- as long as you're fully aware that much of the book has already been overtaken by recent developments.
First off, take a look at the chapter list in this cocos2d forum announcement. Topic selection is good, progression is straightforward. No complaints about the overall structure then, this is indeed a well designed introduction to cocos2d.
One big problem with doing a book like this is that you will inevitably be overtaken by events. Let us take this exchange from the cocos2d forums:
cell-gfx: Reading through the timer example in the book on page 28, you use the schedule:@selector method of scheduling an update to your node. However, when I refer to the cocos wiki, it says to use scheduleUpdate...
pabloruiz55: Yes it would, but as the chapter was written a while back the scheduleUpdate method didn't exist
scheduleUpdate was added in 0.99.3. The version of cocos2d distributed with the sample code as of right now is 0.99.1. The current version of cocos2d is 0.99.5. The changes are substantial enough that people are encountering some difficulty applying the book's code with the current release. So it's pretty difficult to recommend something wholeheartedly when you know people are going to struggle with it through no fault of their own; at the very least, if you publish a book like this you should at least keep the samples up to date with the current release, and a list of updates/errata such as the above, I'm thinking; in a designated blog for book discussions, if nothing else.
Same problem applies to the chapters about tools. It goes over the Zwoptex web version for sprite sheets, not the native version or Texture Packer. The fonts chapter, we were wincing at the Hiero and Angelcode discussion: "Both are very good tools" -- no. No, they are not. Granted that Glyph Designer is brand spanking new right now and no doubt was completely unheard of as the book was written, but someone picking up cocos2d today really needs to be informed about that. Again, this is the kind of thing that would be most properly addressed by something like a designated blog, or perhaps errata updates mailed to registered users.
Another example of this problem is that even the design walkthrough, which is generally good, can be significantly in error. We were brought up short on page 47 of the PDF for instance, with
"When you quit your game ... the applicationWillTerminate method will be called. This is a good time to save your game's state..."
Ah ... no. Not on iOS 4. (Unless you go to some effort to get that behaviour). That would be a perfectly acceptable oversight in a book released in July last year. In December? Not so much. If lead times are so long that a statement that's been wrong for six months can't get corrected for publication, then there really needs to be some mechanism for distributing errata.
Moving on, we were mildly disturbed by the code samples in general. Picking on the Chapter 4 `ColouredStones' example in particular, we load it up to find it's looking for SDK 3.0. Sort that, we get
"Code Sign error: The identity `iPhone Developer: Pablo Ruiz (4LFH26A558)' doesn't match any valid certificate/private key pair in the default keychain"
and it's set at project and target level both. OK, we can sort this out in 15 seconds, but a beginner cannot. Messr. Ruiz overlooking this before uploading, hey we can let that slide. Technical reviewers? Not so much, guys. Especially when we get around to Build and Analyze:
[ screenshot here showing "Incorrect decrement of the reference count..." analyzer error ]
Okay, if you're working for me, and you check in code with any warnings or analyzer results, we will have words. If you check in code with an analyzer error "Incorrect decrement of the reference count of an object that is not owned at this point by the caller", we will have harsh words. That code which would only compile on the author's machine and that contains significant errors made it through to the downloads? The reviewers have not done their job acceptably. Yeah, our standards are high. So should yours be.
That said, with a little coaxing we did get all three of the game samples to run, and they are well chosen to give a good overview of the functionality discussed throughout the book; so we're only mildly disturbed, there is a good bit of value here.
We could nitpick a while more, but you've pretty much got our feeling now; the book is well designed for what it is, which would be more accurately named "Walkthrough of cocos2d Development for the iOS Programmer" than a "Beginner's Guide", that being somewhat of a misnomer. However, it's well designed for the state of cocos2d development prior to iOS 4, which makes reading it now mildly problematic. And that goes even more so for the source code, which is not only somewhat outdated but really should have had much better review before letting it loose on the readers. Valuable, yes; exemplary, not by a long shot.
So clean the code, update it to current recommended practices, update the tools chapters, and put a process in place for updates to stay in sync with continuing cocos2d development; yep, we'd give 2nd Edition a solid five stars as an excellent introduction to cocos2d. What we're reviewing today ... yes, we'd recommend it to someone who asked for the best way to start getting up to speed on cocos2d we knew of, but would make a point of telling them to read the caveats above. Three stars, that's about the best we can muster up. Still, a fine effort by Messr. Ruiz, and we do hope sales go well enough to merit an update!