If you’ve been luxuriating in the joy of developing games iOS-centrically the last few years, it’s a pretty good bet you’ve been using cocos2d-iphone. And it’s also a pretty good bet that the pressures are mounting to acknowledge the existence of other, lesser, platforms, if you get our drift. The path of least resistance to that is to go with the cocos2d-x fork adopted as part of the cocos2d coordinated releases. But up until now there’s been a substantial dearth of documentation for that option, which the good folk at Packt have now remedied:
The first chapter runs through getting you set up and doing the Hello World thing on a Mac with Xcode with the 2.0.4 version, which is the last stable release before the book’s publication date, just in time to be superseded by the 2.1.3 release, although the differences are pretty trivial; and recommends for your tool suite that you pick up Texture Packer, Particle Designer, Glyph Designer, and cfxr. Which we’d agree with across the board.
Chapter 2 goes over the basic structure of the cocos2d framework, introduces C++ to the native iPhone developer and discusses how to live without ARC, or conversely for the C++ programmer how to live with the root class paradigm. Not sure you’d ever manage to square that circle to anyone’s complete satisfaction, but what’s here is a good attempt.
Chapters 3 through 9 go through a series of mini-game examples, introducing
- images (including retina), sounds, sprites, multitouch, bounding collisions
- sprite sheets, bitmap fonts, background music, actions, universal apps
- particles, drawing primitives, vector math
- placeholder prototyping, terrain generation, platformed collisions
- texturing terrain, parallax, sprite nesting, menu and tutorial modes
- Box2D physics worlds, bodies, controls, and collisions
- scenes, transitions, data loading and saving, notifications, accelerometer
That’s one solid amount of stuff to cover in a beginner’s guide! Plus there’s a very nice appendix on introductory vector math applications, nice touch there. And these games are rather polished for tutorial examples. Indeed, our first criticism of the book is that they’re not up on the App Store for you to check out yourself what you’d be learning, which you may recall we thought was a pretty compelling feature of the Creating Games with cocos2d book. But hey, you can see screenshots on the author’s blog here.
Chapter 10 — “Code Once. Retire.” — yep, that’s what we’re probably here for … and it’s a bit of a disappointment. It covers how to set up an Android “Hello World” project skeleton with Eclipse, and some arrangements for hybrid Android/Mac compilation … and that’s pretty much it. For the intended audience, that strikes us as rather a flaw. What would make this a five-star book is if all the samples were available on the iOS App Store, as grumbled about last paragraph, but also on the stores for at least three or four of the platforms cocos2d-x targets, and discussion in the book of just what was involved in customizing the code, assets, and deployment tactics for each.
So, depends what kind of “beginner” you are how valuable you’ll find this.
“Beginner” to cocos2d from scratch? Easy five stars, buy it now.
“Beginner” to cocos2d-x with an oeuvre of cocos2d-iphone code you want to get shipped on other platforms? Useful, but just barely gets you started on anything but porting your Objective-C to C++ code, which chances are you could do on your own if you’ve ever programmed anywhere but the iPhone. If you do have a solid C++ history and at least nodding familiarity with Android project setup, three stars; if not, four stars.
So overall we’ll give it a solid four stars; some more followthrough on deploying the examples onto non-iOS platforms, and we’d give it an unreserved five stars.
Postscript — Other cocos2d-x Resources:
The Wenderlich archives have a recently updated Cocos2D-X Tutorial for iOS and Android: Getting Started and Space Game.