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. Tyong says:

    Hi Steffen, this is my first post. I am impressed by the support of an expert, who else can answer a query on the book, of course the writer himself. Will be posting next after this test post.

  2. Tyong says:

    I am a mainframe developer for 12 years. Am very new to OOP concept. Purchased a book on objective c tutorial by stephen kochan, after finishing it, bought an IOS 5 book by Jeff Lemarche,still currently reading it. In the end , I want to develop iphone games. Am I better off to discontinue reading the IOS 5 book and just go straight into learning cocos2d? Any comment or suggestion is much appreciated.

    • Hard to say. If your goal is to make games, then the iOS book is probably teaching you only about UIKit. But you need at the very least OpenGL experience, or better avoid that by using a game engine such as cocos2d. Specifically for someone new to making games the OpenGL stuff can really be a drag and sidetrack you a lot from actually implementing a game. If you feel comfortable enough with Objective-C I think you should read books and tutorials about game development with cocos2d, or perhaps OpenGL if you really dig the technical side of rendering.

      • tyong says:

        Thanks Steffen, will just complete my ios5 book and get your latest book on cocos2d. Will surely post some questions in the future. About your cocos2d tutorial, is this an online course and what is the cost if you don,t mind asking here.

        • Well for books I’m obviously recommending mine. :)
          It’s written in tutorialesque form, step-by-step and not skipping ahead.

          And there’s also plenty of online tutorials from absolute beginner level to more advanced or specialized ones. For example Ray’s website has tons of iOS tutorials, and the simple cocos2d game tutorial is still a great introduction even though it’s 2.5 years old now (meaning it’s not compatible with the latest cocos2d versions).

  3. Luke says:

    Hey Steffen,

    I’m going to spend the next two semesters developing an iOS game with Cocos2D. Being unfamiliar with Obj-C as well as the 2D engine, I have my work cut out for me. I purchased your book (v3) to help expedite the learning process. That being said, the publication date has been pushed at least two times now, and I simply can’t wait much longer. Are there any other well-established walkthroughs of the Cocos2d engine that you can point me to?

    Thank you for your time,
    ~luke

    • According to Amazon.com the publication date is now September 19th.
      I think Ray Wenderlich has the best tutorials, check the cocos2d category respectively search for cocos2d.
      Unfortunately there are very few tutorials available from anyone that use cocos2d 2.0. Still you can learn some of the basic principles from any beginning level cocos2d tutorial.

      I’m also working hard on the online Cocos2D Essential Reference, if possible I will try to match the book’s release date so it has a companion reference. More details soon on my blog.

      • Luke says:

        I just had to comment…

        The book (3rd ed.) finally arrived and is superb. This is precisely what I was looking for to help get my head around Cocos2d. The chapters on Sprites and Parallax are added bonuses; I never knew the steps to take to optimize texture packing or how to reuse sprites, and this book lays it out quite clearly. I have picked up several more-general coding tricks/tips as well just from reading through your stuff.

        One caveat– Ch07 source code, when opened via .xcworkspace precompiles with one warning and an error (Xcode 4.5):

        1. Xcode wants me to “update to recommended settings” which says it will combine high res. artwork into a single file while building. Should I do this, or will it break something?
        2. It provides and error reading “linker ocmmand failed with exit code 1.” My intuition is that Xcode is having a hard time finding Kobold libraries, but I’m not sure and I don’t know what to do.

        • Luke says:

          I solved my own problem. It appears that some chapters in the book’s source code omit /users/[username]/library/developer/xcode/deriveddata/[chapter]/build/product/debug-iphonesimulator/ [libraries].

          I’m assuming you left these libraries out by choice, as lots of the examples don’t touch them. For some reason my simulator wanted to know where they were, however.

        • “Update to recommended settings” is usually safe. Xcode 4.5 wasn’t available when I wrote the source code.

          I’ll check the Simulator issue, not sure but might be Xcode 4.5 related too.

        • Btw the Ch07 project (Kobold2D version) runs fine on Xcode 4.5. Didn’t ask me to update settings either.

  4. Justin says:

    Hey just wondering if the new version of the book covers things like graphic sizes for the new iOS hardware coming out. Or how to adapt for creating graphics for now possibly six different display frames ( iPhone iPhone HD iPad iPhone 5 iPad mini ).

    Also anything on dealing with ios6’s new way of auto- rotation and game center?

    If so I will buy that fast and tweet it for all the world to read.

    Big fan!

    Justin

    • The display resolutions are listed in a reference and the required file extensions are also explained. But since iPhone 5 and iPad mini aren’t available yet, they aren’t covered. It’s not even clear yet if cocos2d needs additional changes to support them. In general device resolutions are a simple matter of scale, ie design images in the highest supported resolution (or higher), then scale them down accordingly. A tool like Texture Packer (explained in the book) helps tremendously in this process.

      Similar for iOS 6 autorotation, the changes are not in cocos2d yet (Director still uses shouldAutorotateToInterfaceOrientation). These methods are only marked as deprecated though, meaning they’ll continue to work for the time being but generate a compiler warning. In any case I’ll cover autorotation in the Essential Reference online documentation I’m currently writing.

  5. Hey,

    Will this book be available as eBook of PDF?
    I can only find the alpha book on apress.

    Thanks,
    Daniel

    • Yes, the final version will be available as PDF, ePub and Mobi. If you get the alpha version (PDF), the other versions will become available for free.
      I don’t know why the eBook is still in Alpha. I guess it’ll change soon now that the print book is shipping.

  6. kai says:

    Original Source Code (Cocos2D 0.99.x)

    the zip password is what?

    • None of the download archives are password protected. I downloaded 0.99.x to verify and it didn’t ask for a password. You might want to try re-downloading the file in case of corruption or an incomplete download.

  7. Josh says:

    Hi Steffen, is the final version of the ebook out yet? I would like to know before making the purchase. Thanks for the awesome work.

  8. Muser says:

    Is the kindle version the same as paper book?

    Thanks

  9. Kelvin says:

    Hi Steffen, the sample code accompany with this book seems have a problem of switching device orientation in iOS6. They always show in portrait. I tried the orientation settings in both app delegate and project settings, but no luck.. How can I fix it? Thanks~

  10. Jonathan says:

    nm I found the resources at the top of this page.
    Thanks!

  11. gustav says:

    Hi Steffen
    i want to know if i can use the source code of the first edition of the book “learn iphone and ipad cocos2d game development” in xcode 4 or i can use only in xcode 3

  12. gustav says:

    so what can i do to work in xcode with cocos2d or which book can i use and which is the difference between the one source code and the other one

  13. Gerry says:

    Hi Steffen I just bought your cocos2d 2 (third edition). When I’m trying to convert my project into ARC and link cocos2d as static library, everything works and compiles. But when I run it on iphone 5.1 simulator I get this error. Any idea how could I fix this?:

    dyld: lazy symbol binding failed: Symbol not found: _objc_setProperty_nonatomic
    Referenced from: /Users/gerrytan/Library/Application Support/iPhone Simulator/5.1/Applications/83B7CDB8-E29C-4232-A525-C61A81CEE159/hellococos.app/hellococos
    Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Foundation

    dyld: Symbol not found: _objc_setProperty_nonatomic
    Referenced from: /Users/gerrytan/Library/Application Support/iPhone Simulator/5.1/Applications/83B7CDB8-E29C-4232-A525-C61A81CEE159/hellococos.app/hellococos
    Expected in: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk/System/Library/Frameworks/Foundation.framework/Foundation

    • This can occur if you set the deployment target of either the app or the static library target to a higher iOS version than the device/Simulator runs on. Since you run on Simulator 5.1 it’s probably set to 6.0 in one of the targets, most likely the static library target because iOS 6 is the default when creating a new target. That means you can actually select to run on Simulator 5.1 if your app’s target is set to deployment target 5.1 but the code in the static library target will not be compatible with iOS 5.1. So make sure all targets use the same deployment target.

  14. Bobby says:

    I downloaded the source code for both cocos2D and Kobold2D and I noticed that there was an alien.png but not alien-hd.png. Is there a newer resource folder available for download? I just made my own alien-hd.png for now but I’m worried that in future projects I’ll be missing resources that are more important.

    • There’s no alien-hd.png, I don’t have the source in high resolution.

      • Bobby says:

        The book said “The player images alien.png and alien-hd.png are located in the Resources folder of the DoodleDrop project supplied with the book”. No big deal if that’s not the case, I was just worried I might be missing stuff in future chapters.

      • Bobby says:

        I also don’t seem to have a “ScenesAndLayers01 project” described in Chapter 5. Is the source code from the link above “Cocos2D Source Code (ARC) ” and “Kobold2D Source Code (ARC)” or is there a link to the full source code somewhere?

        • Bobby says:

          Please delete all my comments – I re-downloaded the source code and everything’s there. Must have been a partial download or trouble unzipping. Thanks!

  15. Alex says:

    After updating Xcode, I had to comment out all the “FIX_CATEGORY_BOOK”
    from the source code of the book, or I got the following error:
    “note: add a super class to fix this problem
    1 error generated.
    Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1”
    What happened?

  16. Jesper says:

    I have the same issue as Alex mentions above. Any chance you will update the code to work with xcode 4.6?

  17. Wil says:

    After upgrade to Cocos2d v2.x, the CCRibbon is missing. Any good suggestion to replicate the same functionality? We learn CCRibbon from your book and implemented the CCRibbon in many places. Pls help if you can. Thx :}

  18. Hi Steffen,
    Just wanted to say whats up and that your book “Cocoas2d game development for iOS 5” is my first real venture into game programming, well me taking it as serious as i ever was. So far i like the read its pretty informative, but before i bought this book i did not realize actually wrote a third edition to the series. So other than saying thanks right now, that was my initial intention before i read that information, im wondering after I’m done with this book if its really needed to buy the third edition. So in your opinion has Cocoas2d really changes enough for me to have to buy it?

    • It depends. If you find it difficult to adapt to v2 you might want to look into the 3rd edition, on the other hand if you only have a particular issue you can just ask about it on stackoverflow.com

  19. Bekki says:

    Hi Steffen,
    I’ve purchased your book and have been following the chapter on adding cocos2d to a UIKit view. Everything seems to be right except the scene and animations never show. I have verified that all the methods in HelloWorldLayer are getting called and nothing is nil, but nothing ever shows in my view. Have you ever seen anything like this?

    Thanks!

    • Bekki says:

      Nevermind, I got it fixed. I had commented out the section setting the director view while i was debugging a different issue.
      Thanks,
      Bekki

Leave a Reply