Book: Learn Cocos2D 2

Learn Cocos2D 2 (Third Edition)

Release Date: August 29, 2012

Explains both Cocos2D 2.0 and Kobold2D v2.0 side-by-side. All source code projects and descriptions have been updated to fully utilize ARC (automatic reference counting). ARC makes learning Cocos2D even easier and results in faster code with fewer bugs.

Also explains TexturePacker, PhysicsEditor, Tiled, Glyph Designer, Particle Designer and other tools. Source code is compatible with Xcode 4.4, iOS 6 and Mountain Lion (Mac OS X 10.8).

Download Source Code (3rd Edition):

Cocos2D Source Code (ARC) (Cocos2D v2.0; includes 12 Cocos2D ARC templates)
Kobold2D Source Code (ARC) (Kobold2D v2.0; uses Cocos2D v2.0)
Download Kobold2D and install it to get the Kobold2D & Cocos2D Xcode documentation.

Exact game engine versions used by the book:
Download cocos2d-iphone v2.0 and/or download Kobold2D v2.0.4

Second Edition

Release Date: November 9, 2011

Explains Cocos2D v1.0, introduces Cocos3D and Kobold2D. Also explains TexturePacker, PhysicsEditor, Tiled and other tools. Source code is compatible with Xcode 4 and iOS 5.

Download Source Code (2nd Edition):
Source Code (Cocos2D v1.0.1)
Download Kobold2D

First Edition

Release Date: December 2, 2010

Learn iPhone and iPad Cocos2D Game Development book cover

Explains Cocos2D v0.99. Source Code is compatible with Xcode 3 and iOS 4. Explains tools like Zwoptex, VertexHelper, Hiero, Tiled and others.

Download Source Code (1st Edition):
Original Source Code (Cocos2D 0.99.x)
Updated Source Code (Cocos2D v1.0.1)

Full Description

Create compelling 2D games with Learn cocos2d 2: Game Development with iOS. This book shows you how to use the powerful new cocos2d, version 2 game engine to develop games for iPhone and iPad with tilemaps, virtual joypads, Game Center, and more. It teaches you:

  • The process and best practices of mobile game development, including sprite batching, texture atlases, parallax scrolling, touch and accelerometer input.
  • How to enhance your games using the Box2D and Chipmunk physics engines and other cocos2d-related tools and libraries.
  • How to add UIKit views to cocos2d and how to add cocos2d to UIKit apps.
  • The ins and outs of the Kobold2D development environment for cocos2d and its pre-configured libraries, including Lua.
  • Best of all, this book will have you making games right from the very start. It guides you step-by-step through the creation of sample games. These fun examples are modeled after popular App Store games and teach you key concepts of the new cocos2d 2 game engine and relevant tools like TexturePacker (texture atlas), PhysicsEditor (physics collision shapes), Particle Designer (particle effects), Glyph Designer (bitmap fonts), and others.

This book offers a rock-solid introduction to creating games made entirely with cocos2d and little or no iOS SDK and OpenGL code. It also details alternative implementations, identifies the best free and commercial tools for cocos2d game development, features coverage of the author’s improved cocos2d game engine (Kobold2D), and even helps you enhance your game’s marketability on the App Store.

Who this book is for

The book is aimed at beginning game developers looking for an easier and even more powerful way to create compelling 2D graphics using OpenGL and Objective-C. It is assumed that the reader will have some knowledge of object-oriented programming and the Apple and iPhone/iPad developer environment.

Learn Cocos2D Book Reviews

142 Responses to “Book: Learn Cocos2D 2”

  1. Young-Jin Lee says:


    I was trying to put a cocos2d app into a UIKit app by following the chapter 15 of your book. Although I followed the steps exactly, I got tons of errors from the Box2D codes. “Box2D/Collision/b2BroadPhase.h’ file not found” is one of many errors I got when I tried to build the code. But, b2BroadPhase.h file is included under the lib folder that I added.

    Can you help me solve this problem? By the way, I am using Xcode v.4.3.1. and cocos2d 1.0.01.

    Thanks in advance.

    • Keep in mind that you need to add the Box2D folders to the Build Settings “Header Search Path”. Do not use “User Header Search Path” though since Box2D headers (quite uncommonly) #include/#import headers with angle brackets (reserved for system headers) instead of quotes.

  2. Paul Masri says:

    Hi Steffen,
    Thanks for a great book, with a really readable style. Having got an app out there by writing pure Objective-C, I wish I’d come across libraries like cocos2d/kobold2d earlier. (Mind you it’s still worth understanding the basics!)

    I have a couple of questions. In chapter 4 (2nd ed), you say “You can find these and other useful math functions in the CGPointExtension files in the cocos2d/Support group in the Xcode project.” Sorry for being a bit dim but where do I find this cocos2d/Support group and these files?

    As you say, you’ve got a chapter about transitioning to Kobold2D, which I’ve read ahead of working through from the start, but all the code before that chapter is geared towards Cocos2D. When I came to download Cocos2D, I actually ended up with Kobold2D v1.0.1, so there are already some differences with the code in the book. What I’m wondering is: if Kobold2D is there to reduce the learning curve and deal with some logistical issues of Cocos2D, am I doing things the hard way by trying to learn Cocos2D and then transition?

    Cheers, Paul.

    • If you look in the cocos2d archive after extracting, the support files are in the /cocos2d-iphone-xxxx/cocos2d/support folder (xxx being the version number). Could be that in cocos2d 2.0 the path or filename have changed. You should still be able to locate it with spotlight searching for “drawcircle” or “drawpoly”.

      Second question is a yes and no. The 2nd edition of the book will be harder to work with Kobold2D because there are some minor differences. In the next edition you’ll be able to work with both and in numerous places I’ll mention the things that Kobold2D users can either skip, or use instead because it’s already built-in.

  3. chris baxter says:


    just working my through your book. its really good and thank you.

    I have a question on particle systems. Right now I have a particle effect created in Particle designer. a bit like the snow falling. (I tried using box2d , bu the perfomance got increasingly worse, but nice physics effect when spirites landed, shame).

    Anyway, as the particles hit the floor, i want to to built up the surface where they land to give the effect of snow building up. is there a way to retain particles, or at least determine where they land so i can add a small spite ?

    can you help me with this problem ?

    • The particles in a particle system can not be influenced at all other than with the parameters you can set in Particle Designer and code. They don’t collide, you don’t even have access to the position information for individual particles.

      For that to work you’d have to use a different approach. Like you said, animating individual sprites with a physics engine. But unless this is a central aspect of your game’s design, it’s not worth doing because it simply eats up too much performance. There are particle engines that can do that, but they’re typically found only in high-end game engines for PC and consoles, and even there are sparsely used.

  4. Etteba Idoteyin says:

    Dear Stephen,

    Please I will like to know how to manually change the orientation of my saved BMFont. With instruction from your learn Coocs2d book, I used Hiero and it saved the png file upside down. Also, when I run my project with the upside down files, all I get are funny characters displayed.

    Can you help me with this problem?
    Thanks in advance.

    • Hiero is buggy and the image being upside down is a common issue. There’s no workaround other than flipping the image with an image program every time you saved the font in Hiero. Glyph Designer is an alternative and I also saw a very similar bitmap font program on the App Store.

  5. Chris baxter says:

    Hi Steffen

    Thanks for the book. its been a great help to me on my first cocos2d / kobold2d project.

    I have a question on tilemaps. is it possible to create a tilemap and have endless scrolling on the x and y axis ?


    • Not easily. You would have to either create the tiles at the scrolling border (randomly if you truly want endless scrolling like Doodle Jump) or otherwise stream in new tiles. I remember someone on the cocos2d forum actually had a working tilemap streaming class.

  6. James D says:

    I need the essentials app that is to be used with the book (which I have and is very good), but I’ve gotten to the chapter when the essentials app is required, and for some reason i can’t locate this anywhere?

    Could you please help?


  7. Kazzy says:

    Hi Steffen,

    I’ve been reading book and it’s great, but I want to learn cocos2d 2.x as well as how to use ARC in cocos2d. I remember you said on the forum the 3rd edition is coming in July/August. Do you have definite date for release? And if it’s coming soon, is it worth while to read the 2nd edition meantime?
    Kindly please leave a comment.

    • No definite date, I myself have to guess the release date unless I keep asking my editor. From what I can see is that the book has been indexed, now it needs to be page proofed and then it can go off to the press. My best estimate right now is mid to late August.

      It’s worthwhile to read the 2nd edition. It only covers cocos2d 1.x though but the differences aren’t that huge.

  8. Richard says:

    Hi Steffen,

    you have written a great book ! well done !

    I have a question that I followed the example in chapter 4 to write the first game, but I got the player’s background in white but not the spiders; I have compared my version with the source code of the book and can’t found any code which may caused the problem. is there something I have missed ?


  9. bravebox says:

    Well written book thanks.

    Im having trouble with the exercise files all seem to be missing the base SDK when building. When I create a new cocos2d project im fine, it only occurs when opening a exercise file (any). Regards

  10. Ben says:

    I wanted to pre-order the 3rd edition of your book from But I can’t seem to find it. Do you know when they will have it available?

  11. Rudi says:

    I have buy the alpha book.
    I am interesting on tourn based game with game kit…. Can I see samthing on this in the near future? On kobold2d?

  12. Flemming says:

    Do you know when(if) a kindle edition of the 3rd edition will be available?

  13. Benjamin says:

    Hi Steffen,

    I would like to pre order your book (not the ebook)…and I took a look at amazon.
    So my question is:

    why is your book on (
    just 20.65 $ (= 16.50€) and when I look at (
    it’s 33,99€ (=42,55$) ?

    And another question:

    how detailed are your explanations about cocos2d? I mean do you miss out something when you explain two engines in one book or is it a big one?
    Is there a directory out now?

    Kind Regrads

    • Commonly overlooked when comparing USD prices and EUR prices is the fact that USD prices are listed without VAT (Mehrwertsteuer). For higher prices this often makes up most of the difference. Then add shipping & handling and the difference typically becomes marginal (you get free delivery with within germany).

      I did a test-order on

      Items: USD 20.65
      Shipping & Handling: USD 7.98
      Total Before Tax: USD 28.63

      Then add 19% import tax (VAT) to that and you get just over $30. In EUR this is about €25. This is for “18-32 days shipping” option. With “8-14 days shipping” you pay USD 12.48 shipping. And the 2-4 days shipping option (air mail) costs more than the item (USD 30.48)!

      So you only pay a little more, and that’s mostly the convenience of getting the item shipped to you within 1-2 business days. Ie the cost of distributing the book to and within Europe (including any customs fees/taxes) is already factored in.

      Finally, you have to consider the average income in the respective countries. Many companies offset their prices based on the target country’s average “buying power”. So in rich countries items cost more, in poor countries they cost less (or you couldn’t sell them at all).

      The differences between cocos2d and kobold2d as far as cocos2d programming is concerned are minimal. I go in depth on cocos2d more because there’s more manual labor required, ie to setup ARC.

  14. Benjamin says:

    Thanks for your accurate explanation.

    But I have another question:
    In your Second Edition Book there are 532 pages and in the Third Edition only 350 pages. Is there something written down in the SE book thats not in the TE book?

    • That must be a miscount. I know the book was originally put in as a “350 pages” book before I began writing it (and it turned out to be a 400+ pages book in the 1st edition). So that’s probably just their default page count. The page count for the 3rd edition should still be about 500 pages or more.

      • Benjamin says:

        And a last question: If I order the book on the German Amazon Site it means they print the book in Germany or elsewhere in Europe and thats the reason for short sender time?

        Looking forward to your book :-)

  15. Charles says:

    I am reading the alpha version of of your Third edition book. A great and clearly written book. However o page 93 I get a warning and an error on

    player.position = CGPPointMake(screenSize.width /2, imageHeight /2);

    The warning is: Implicit declaration of function ‘CGPointMake’ is invalid in c99
    The error is: Assigning to ‘CGPoint’ (aka struct cgpoint) with an expression of incompatible type ‘int’

    Google could not help me here.
    Any help is appreciated as i am stuck.

    • Thanks!
      If it really says “CGPPointMake” then that’s the issue. It should be CGPointMake with only one P.
      On the other hand the warning prints it correctly. CGPointMake is always included since it’s a CoreGraphics framework function. I can only explain this if either CoreGraphics.framework is not included in the target, or wasn’t imported. The latter would be really weird because it’s normally in the prefix.pch and also included if you #import “cocos2d.h”.

      The alternative is to replace CGPointMake with ccp, that ought to work as well.

      • Charles says:

        Darn it. You are right one ‘P’ to much. This is embarrassing. I must read over it at least 50 times.
        Sorry to waste your time on this. I will walk with ashes on my head for a week.
        Thanks for you help.

  16. Benjamin says:

    Ordered it yesterday :-) expected date of delivery on September 5th. I hope next wednesday comes fast or amazon is even faster!

    • Thumbs up! :)

      I don’t know how the distribution process works, I can imagine that the books are first shipped worldwide ahead of the release, so it’ll be available worldwide at around the same time. But it’s also possible they just print it in europe too.

  17. Michael Teeuwen says:

    Great work Steffen! I bought the digital version yesterday and it’s a nice read.

  18. Ben says:

    It is August 30th today.
    This title has not yet been released.
    This title has not yet been released.
    Derzeit nicht verfügbar.

    I have actually been waiting for this to come out. Very disappointing…

  19. Renato Moya says:

    Steff, I bought the book last week, I was hoping I could read it on my iPad but the ePub version isn’t up yet :(

    Only PDF version available.

    Any real release date? August 29th 2012 was not it. :)

    Thank you.

  20. seb says:


    Is it this book ok for completely objective-c and & cocos2d beginner ? I”m a developer, but lately (3 years) I have mostly coded in action-script 3. So, can I learn the basis of the language and in the meantime game development basis with this book ? Or do you recommend me to read some other book first ?

    Thank you

    • I would say so. I don’t explain Objective-C like a good Objective-C book or tutorial would, but if you’re able to pick up a language’s features just by seeing them being used you should be good to go. Just keep an ObjC reference in reach.

Leave a Reply