Creating Games with cocos2d for iPhone 2

I’m happy to share my new book, Creating Games with cocos2d for iPhone 2.packt_book_cover_small

Creating Games with cocos2d for iPhone 2 takes you through the entire process of designing and building nine complete games for the iPhone, iPod Touch, or iPad using cocos2d 2.0. The projects start simply and gradually increase in complexity, building on the lessons learned in previous chapters. Good design practices are emphasized throughout.

Why This Book Exists

I will dispense with the general marketing blurbs here.  If you want to read the “official” promotional information, it is all in the first post of this forum thread.

Instead, I want to share, from a developer’s perspective, why you might want to read this book.  Most developers learn the basics of cocos2d for iPhone v.2.0, and subsequently hit a wall.  We have all these interesting classes that are really powerful, like CCLayer, CCSprite, actions, etc.  How can we put these things together and make something equally interesting out of them?

That is the “gap” this book aims to fill.  Rather than take the beginner’s book approach, where we spend several pages explaining what a sprite is, how it is drawn, etc.  “Creating Games” skips many of the generalities and jumps right into the reason we are here: building games.   This is the book I wished I had in hand when I was first exploring cocos2d for iPhone.

Class by class, method by method, the text explains the “good parts” of why we are building the code in this fashion.  All the “good parts” are explained in detail: from building with Box2D to GameKit Bluetooth integration, and even how to build in “artificial randomness” into a Match 3 game, so you never run out of moves.

Each chapter is a complete game, and all source code is available as a download from the publisher’s web site. The games cover a wide variety of game types, and the games become more intricate and complex as the book progresses.

The games included in the book are:
Chapter 1: Memory
Chapter 2: Match 3
Chapter 3: Mole Thumper
Chapter 4: Snake
Chapter 5: Brick Breaker (with Box2D)
Chapter 6: Cycles of Light (iPad with Bluetooth integration)
Chapter 7: Pool (with Box2D)
Chapter 8: Scrolling Shooter (using Tiled)
Chapter 9: Endless Runner

Book Giveaway

We are giving away two free copies of Creating Games with cocos2d for iPhone 2!  The contest runs until January 29, 2013.  To enter, all you need to do is post why you want the book to the book’s forum thread.  To see the particulars of the contest, read this post: Book Giveaway

13 Responses to “Creating Games with cocos2d for iPhone 2”


  • I really want to take my cocos2d knowledge to thenext level. I was thinking about learning some OpenGL ES 2.0 but I think this acctually better. I want a deeper understanding of how the framework works.

    :)

  • I really want to take my cocos2d knowledge to thenext level. I was thinking about learning some OpenGL ES 2.0 but I think this acctually better. I want a deeper understanding of how the framework works.

  • Bought, reading! Thanks for writing this. :)

    Quick note: the Chapter 2 example project has a bug I’ve not found yet – when compiled on XCode 4.5.2 and run on the simulator, the game stops responding to gestures after a varied number of turns. On some runs, I get 10 moves, on some, the game stops working after the first run. Nothing relevant is logged, so debugging this as a Cocos2D noob is a bit hard. Rest of the example projects seem to work fine.

  • Cant wait to see it on iTunes for download :) Any thoughts when it should be available?

  • Sulka Haro: I’ve never seen that bug on my system. Are you using the project from the code bundle? Which version of the simulator are you using? 6.0, or an earlier version? Which device is the simulator set to (iPhone, iPhone 3.5″, iPhone 4″, iPad, iPad retina)? Also, have you tested on a device, or just the simulator? I suspect it might be a bug in the simulator, one that only shows up in some environments.

    Digitalforms: I’m not sure why the book is not in the iBookstore – it seems to be available everywhere else. One option would be to pick up the eBook from PacktPub.com, and download it as a PDF, which you can then load to your iBooks library.

  • Sadly when you load a pure pdf to iTunes, you dont have access to table of contents :(

  • Just bought it, i got it right – no table of contents :( ((

  • I’d have the book to begin developing with this library my first game ;-)

  • I just picked up the book off Amazon and will breeze through it this weekend. I don’t want my second game to take as long to develop as my first one, Fire Escapes.

    Thanks!

    http://fireescap.es

  • The first book is very very good!
      But I have a question: Have you made any update to the latest versions of IOS and Cocos2d?

    Cause I’m having problems bugs that Xcode does not identify …

      This error points to the line 14 in the file main.m

    23/02/2013 18:04:22.060 DoodleDrop [637: c07] *** Assertion failure in – [CCTimer initWithTarget: selector: interval: repeat: delay:] / Users/Tiago/Desktop/Desenvolvimento/COCOS2D-Livro / Cap1-Config/Cap 1 – DoodleDrop/DoodleDrop/DoodleDrop/libs/cocos2d/CCScheduler.m: 111
    23/02/2013 18:04:22.276 DoodleDrop [637: c07] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘Signature not found for selector – does it have the Following form? – (void) name: (ccTime) dt ‘
    *** First throw call stack:
    (0x1d55052 0x1942d0a 0x1cfda78 0x11cd2db 0x691b7 0x6b642 0x50c2c 0x509fa 0xc9aae 0xc9893 0xc923a 0x4d8f5 0xc8fc2 0xc8940 0x8429d6 0x8438a6 0×852743 0x8531f8 0x846aa9 0x2a20fa9 0x1d291c5 0x1c8e022 0x1c8c90a 0x1c8bdb4 0x1c8bccb 0x8432a7 0x844a9b 0xc83f6 0×2405)

    If you can help me it would be a great help. And send me the link to the book’s first update has.

    Thank you!

  • @Tiago: Thanks for the kind words. I’m not really sure what is causing your error. The most likely cause looks like you have scheduled a selector that doesn’t exist. For example, if you are using [self scheduleUpdate]; but don’t have a corresponding method named update:(ccTime)dt in your class. At least, that is what the error message seems to e saying.

    I have not seen any major problems with the code using the latest versions of iOS or cocos2d. I have upgraded the games as far as cocos2d 2.1 beta 4, and there are only a few issues, mostly to do with Box2d integration and the change from PhysicsSprite to CCPhysicsSprite. There is a document explaining the changes for 2.1 at: http://www.cocos2d-iphone.org/forum/topic/131814/page/3#post-338954

    For errors, it is a better idea to post a thread in the forums, rather than as comments on this blog post. A lot more people will be available to assist on the forums rather than here.

  • Very thanks @Dragyn!!!

  • Thank Paul for writing up this book! I really appreciate it! Loving the fact that the book is about teaching how to make use of Cocos2D in real project. Once again, thank you.

Leave a Reply




Social Widgets powered by AB-WebLog.com.