Search This Blog

Sunday, January 16, 2011

(Book Review) Cocos2D – Its raining books, Hallelujah!

Till just a few weeks ago, there were no real books one could read on Cocos2D game programming. While there are an almost infinite number of web tutorials, a book has a different charm - it is usually more structured and hopefully better researched. A few weeks ago, the first book on Cocos2D surfaced, "Learn iPhone and iPad cocos2D game development" by Steffen Itterheim. I bought it on day 1 of its release, and posted my review here. In short, it was well written and, well, the very first book for cocos2D, so it had that first mover advantage.

The other book I am eagerly waiting for is Rod Strougo and Ray Wenderlich's book "Learning Cocos2D". The book is yet to be released, but I get the feeling it will be more 'advanced' than the other available books.

In the mean time, I was contacted by another company, Packt Publishing who sent me an email to review a new book from them: Cocos 2D for iPhone 0.99 - Beginners Guide by Pablo Ruiz.

Here is the introduction of the book, in the Preface:

"This book will teach you the fundamentals of how to write games with this framework. As this book is meant to give you a basic knowledge of the most important aspects of Cocos2d, it will cover a lot of subjects very quickly. However, do not worry! Almost every chapter will include tasks for you to complete and examples for you to practice. Throughout this book, we'll make three different games and each chapter will build on the previous one, but can also be considered independently, so feel free to skip to any chapter that interests you."

So this post is a review of this new book by Pablo.

Full Disclosure: I was contacted by the company to review their book - they gave me a free e-copy so I could read and comment. Beyond this, I have no monetary or any other form of profit/benefit from this post. In other words, if I thought this book is crap, I can call it crap. If I think its good, I can call it good.

So how is Pablo Ruiz's "Cocos2D for iPhone 0.99" ?

The Good

  1. Its 350 pages of relevant content. The author dives into topics quickly and gets to code examples very soon.

  2. It covers the usual topics like fiddling with sprites, more details on actions, scene and menu management, particle systems, cocosdenshion

  3. I liked the fact that the examples Pablo chose of games are better than 'stupid games that only prove a concept'. For example, "Chapter 2:Playing with Sprites" is a 54 (approx) page chapter which incrementally goes about building a board game where you align stones based on color by swapping them around and then when you align them, the stones destroy themselves. In this 50 page chapter, he goes through the basics of CCSprite, using CCTouchDispatcher for touch management, using Zwoptex to create Sprite Sheets,using CCTextureCache to pre load images for faster response time and even a few lines of OpenGL (basic stuff like drawing a box around an item you select)

  4. He continues the same board game across Chapters 3&4 (another 55 odd pages), where he embellished the game with actions (the usual CC actions along with the ease in action effects). There is a nice page in his book that shows the animation path of each ease action. It looks like it was copy pasted from some standards reference - if so, then you may already know about it - but to me, it was nice to see the easein/out effects on one page. Finally, in Chapter 4, he shows us how to add fonts and text labels to the game and goes through the basics on how to create your own font with CCBitmapFontAtlas.

  5. While the board game was interesting, I was getting bored. Fortunately, at Chapter 5, Pablo stars a new game that basically is called "Aerial Gun" which is a shooting game. You control an airplane while enemies approach you - you have to kill em. In this chapter his focus is on the basics of the game - sprite movement, handling accelerometer based movements, how to fire bullets (bullets stored in an array so you see a spurt of them), collision detection

  6. Then, in chapter 6, he adds options and other menus to the game, including telling us how to use the basis NSUserDefault class to store preferences

  7. Finally, in chapter 7,he integrates the Cocos2D particle system into his game to give explosion effects. One thing I liked was it covers the meaning of all the attributes of a particle system (again at a cursory level). Specifically, I liked the section where he covers how to give an explosion effect when your enemy is hit including telling us how to make the particles move correctly. All of this is directly by manipulating the particle parameters he briefly explained earlier. And then he finishes off with using ParticleDesigner, which is pretty much the defacto particle design tool, it seems

  8. In Chapter 8, he covers background panning using tilemaps. Nothing new or unique here. But if you don't know tilemaps, here it is.

  9. Chapter 9 covers the CC Sound engine. He covers both SimpleAudioEngine and CDSoundEngine

  10. What stands out from the others in this book is the chapter on Chipmunk.  Chipmunk is a physics engine that can add realism to your games (like the toppling monuments in angry birds). Most tutorials and books cover Box2D (even Steffen's book I reviewed earlier). Box2D seems more able, but is reasonably more complicated. And I really wanted a good reference to chipmunk (as a beginner). I was very happy to see Pablo cover chipmunk. Just for that, I'd give him kudos. And also, he goes through several pages in building a relevant game - a totem block, that rests on top of various blocks of different shapes. Your goal is to remove the blocks without the totem falling on the floor.

  11. There is also a chapter on OpenFeint - I liked it. Frankly, I never knew about it. OpenFeint is a software library you can link your code with that allows your game to become "social". In other words, you get access to leader boards, get notifications on new scores from your buddies in your network, connect and post messages to Face Book and more. Yep, you guessed it. It can also become a nightmarish tool if you choose to abuse it (remember those beyond irritating messages from all your friends in facebook about some idiotic occurrence in some mafia game they were playing etc.) Used properly, OpenFeint looks like a very nice tool and Pablo covers it well.

The Bad

  1. The book is hurried. Just too hurried. When you start focusing on a topic into the next level of detail, you feel like the author is trying to complete a race in record time. While at first glance, it looks like he has spent time with details, when you really want to understand something new, you feel he should have spent more time with details.

  2. Code level commentary is high-level and has errors. Consider for example, the chapter on Chipmunk. This was my first point of interest, so I decided to actually try out his examples. I was not given his resource file zips, so I had to type them in myself. The instructions were cursory at best:

    1. Example, he just says "rename HelloWorld" to "GameScene" (no further instructions, and it is not just renaming - you have to rename more than one part, and refactoring was a better approach as far as I feel)

    2. He says "in init method of GameLayer class, change space gravity to 0,-200" without saying where that line would be and what are we looking for. Again, basic stuff - if you know your stuff, you don't have an issue. But if you are a beginner, you are left wondering

    3. Finally, he asks us to introduce a line declaring a totem variable, which never compiles because the instructions forgot to tell us to declare it first (and there too, he says in another example "declare an ivar" - thats all). Again, not an issue for those who know, but if you are really a beginner, you will feel lost at his pace and choice to ignore details.

    4. So basically, you either describe it well enough and the reader can figure out errors on their own, or, you describe it at a high level but make sure the code has no errors. Again, like I said - I did not get enough time to actually try his other examples. Unfortunately, the first chapter I did try to get into details (chipmunk) left me floundering (remember I am a beginner to cocos2d, and am supposed to be a target audience for his book as per the preface)

  3. There may be other issues, I am on travel, so I could not do a thorough read.

Verdict - Better than Steffen Itterheims Cocos2d book?

Frankly, from what I read so far, I don't think so. While Pablo's book covers more topics, the one chapter I actually decided to dive into came out with several errors.  Steffen's book is more thought out and not hurried at all. And I'd say there i around 60-70% intersection of topics between the books. And unless  I try out more of Pablo's code in the book, I can't honestly say it is the book for beginners.

But besides that, it covers enough topics to be of interest. I think if Pablo spent more time with details on the book, it would be a treasure trove. Also, there is limited (or no) handling of the more advanced Cocos2D functions like isometric tilemaps, Cocos2D Camera, Parallax scrolling etc.

Having said all of the above, I think the author will likely improve the quality of the book in future versions.

Should you buy it?

Well, if it was the first book, I would buy it. Since I already have one book and I will surely buy the one by Rod  & Ray (just because of the reputation), it makes buying this book a not-so-easy-choice. For those who choose to buy it, it will give you lots of help and a great head start. But be expected to be rushed and brace yourselves for errors in code.


  1. We are expert in Handling, Packers And Movers jaipur and Packing & Shifting of Household Goods, Office goods, Commercial Equipment and Car, Logistics and Transportation.Packers And Movers Jaipur

  2. Transporting of personal goods or commercial goods should always done in the most cost effective manner. We would recommend you to consider our “Instant Call” services to compare quotes and shortlist your provider.
    packers and movers satna
    packers and movers bhilai
    packers and movers in cuttack
    packers and movers in durgapur
    packers and movers in meerut
    packers and movers rajahmundry
    packers movers jodhpur
    packers and movers kakinada
    packers and movers korba
    packers and movers dhanbad


  3. افضل شركة تنظيف مجالس بالدمام افضل شركة تنظيف مجالس بالدمام
    شركة تنظيف سجاد بالدمام شركة تنظيف سجاد بالدمام

    شركة تنظيف كنب بالدمام شركة تنظيف كنب بالدمام
    شركة تنظيف سجاد بالخبر شركة تنظيف سجاد بالخبر
    شركة مكافحة البق بالرياض شركة مكافحة البق بالرياض