Kobold2D: Cocos3D Project Template

On June 25, 2011, in cocos2d, cocos3d, Kobold2D, by Steffen Itterheim

Today I completed the first draft of the Kobold2D chapter which will be in the second edition of the Learn Cocos2D book. In that chapter I’m also giving you an introduction to cocos3d, the official 3D add-on library for cocos2d. I ported cocos3d’s Xcode project template to Kobold2D and spiced it up a little with some cocos2d nodes in the back- and foreground:

Notice the “incoming network connection” warning. This is caused by the iSimulate library which is distributed with Kobold2D and activated by default for Simulator builds. You still need to buy the iSimulate App to benefit from it though. If you don’t you can also choose to ignore the dialog or simply disable iSimulate by commenting out a line in the project’s BuildSettings-iOS.xcconfig file.

I’ve also had great fun with the augmented reality option that the cocos3d CCNodeController class provides. And setting it up is one line of code. Here’s the “camera as live background” demo in action:

Since a picture doesn’t really do it justice, here’s a video:

Admittedly it could run a little faster on my iPhone 3G. It’s pretty taxed and averages around 20 fps with the camera background view and rendering a 3D model. My iPod Touch 4 averages at around 40 fps and it feels a lot smoother.

Kobold2D Todo List

One of the biggest items on my todo list for Kobold2D is to design the website and get rid of the “coming soon” page. This includes setting up the wiki and filling it with content, documentation for the most part. And, well, paying $150 each month because I don’t see any alternative to using Confluence. I want to enjoy working on documentation, and I want you to enjoy browsing and reading it.

I also want to create more template projects. Currently, as you can see in the first screenshot, there’s Hello Kobold2D (iOS & Mac), Hello Cocos3D (iOS) and Hello Cocos2D-X (iOS). I want to add two more templates, one for Chipmunk with SpaceManager (iOS & Mac) and one for Box2D (iOS & Mac). I also want to add the projects from my book as project templates, namely Doodle Drop, the Shoot ’em Up game, the Orthogonal and the Isometric Tilemap projects, and the Cocos2D With UIKit project (all iOS).

Even though Kobold2D won’t have Xcode 4 Project Templates I still want to give you a quick and easy way start a new project based on one of the template projects. Notice the distinction between “project template” (those in Xcode’s New Project dialog) and “template project” (a regular, already existing project). I started writing a tool that allows you to create a copy of an existing Kobold2D template project and rename it, so that the workflow is just as convenient as doing it within Xcode. It works for the specific template I tested it with, but I still have to design the user interface and make the code fail-safe.

In case you wonder why Kobold2D won’t have Xcode Project Templates: they are not nearly as powerful as they would have to be. And they’re a pain in the rear to create and maintain without some tool support. But worst of all, you have no way of including files in an Xcode 4 project template that must not be added to the Project Navigator. Like, for example, .xcodeproj files.

Cocos2D Embedded In A Cocoa Touch App

On June 12, 2011, in book, cocos2d, by Steffen Itterheim

I just completed this project for the new book chapter about embedding UIKit views/Cocoa Touch in a Cocos2D application. In that case I embedded the Cocos2D view in the View-based Application template and added some controls to start/stop the cocos2d view and change scenes. Here’s the result:

It also correctly auto-rotates. But I noticed an odd bug with auto-rotation enabled for all orientations: the view is designed in portrait mode. If I start the App on my iPod Touch 4 while holding the device in landscape mode, then rotate back to portrait mode once the app has started and enable the cocos2d view, for some reason this causes my device to reboot! I see a transparent white color drawn over the entire screen before the screen goes black and the Apple logo appears.

If anyone has any idea what might be causing this behavior, please let me know. As far as I debugged it is not the initialization of the EAGLView class itself, a scene is already running or about to be run.

I’m guessing it might have to do with the EAGLView initialization, since I rely on Interface Builder to initialize the view. I simply dragged a View object onto IB and changed the class from UIView to EAGLView. Maybe the EAGLView default settings are not supposed to be used and I do need to create the EAGLView manually?

Tagged with:  

Cocos2D Podcast with Michael Daley

On June 11, 2011, in cocos2d, podcast, by Steffen Itterheim

The latest Cocos2D Podcast has been out for a few days and I totally forgot to post it!

Mohammad Azam and I talked with Michael Daley, author of the Learning iOS Game Programming book and one half of the 71Squared development team. You know, the guys who made Particle Designer and Glyph Designer.

Cocos2D Podcast with Michael Daley

Cocos2D Podcast on iTunes

Cocos2D Book Update: Progress Report

On May 29, 2011, in book, cocos2d, by Steffen Itterheim

It’s coming along great!

I completed the revisions on Chapter 1 through 5. The entire source code is now updated to use cocos2d-iphone v1.0.0 rc2. To make future code updates easier I also wrote a script that allows me to copy a newer cocos2d version to all projects, which essentially does Steps 1 & 2 described in the Updating Cocos2D in an Existing Project tutorial.

Most Notable Changes

Chapter 4 now includes a description of Glyph Designer for making Bitmap Fonts, and only mentions Hiero on the side. Glyph Designer is the better tool hands down.

Chapter 5 has seen a revision of the paragraph that explains subclassing from NSObject. I think I went too far off course here and subclassing from CCNode will make a lot of things easier while still giving the same benefits regarding class composition.

In Chapter 6 I decided to replace all descriptions of Zwoptex with TexturePacker as the preferred tool for making texture atlases.

For a while it looked like Zwoptex and TexturePacker would be competing on the same level. But recently Andreas Löw (TexturePacker & PhysicsEditor) made the move to work full-time on his tools, whereas Robert Payne is busy with a full-time job. I think the prospects are looking much better for TexturePacker now, and it is already leading in terms of features and update frequency.

That’s it for now.

Learn Cocos2D Book Source Code Update

On May 26, 2011, in book, cocos2d, by Steffen Itterheim

The most frequent questions I get from readers of my Learn Cocos2D book:

  • “Where can I download the source code?”
  • “Why do I get compile errors in CCLabel?”
  • “Is there an updated version of CCAnimationHelper?”

They all boil down to the fact that the book was written against cocos2d-iphone v0.99.5 with some projects using v0.99.4 and a few even had used v0.99.3.

Unfortunately this is also why some readers deducted one or more stars in their Amazon book reviews. Even more unfortunate because the changes that break the code were entirely cosmetic (renamed classes, function parameters removed or re-ordered, deprecated functions in favor of others). All changes required only fixing the lines using one of these outdated classes (CCLabel, CCLayerColor) or functions (bitmapFontAtlasWithString, frameWithTexture, …).

Quick List of Changes

I kept track of the changes I made to the source code. This is what it boils down to:

  • remove: EAGLView viewWith… -> remove last parameter: preserveBackBuffer:NO
  • remove: CCSpriteFrame: frameWithTexture -> remove last parameter: offset:CGPointZero
  • remove: CCAnimation: animationWithName -> animationWithFrames & remove last parameter: frames
  • rename: CCLabel -> CCLabelTTF
  • rename: CCBitmapFontAtlas -> CCLabelBMFont
  • rename: CCBitmapFontAtlas: bitmapFontAtlasWithString -> labelWithString
  • rename: CCXxxxxTransition -> CCTransitionXxxxx
  • rename: CCColorLayer -> CCLayerColor
  • rename: CCQuadParticleSystem -> CCParticleSystemQuad
  • rename: particle system: centerOfGravity -> sourcePosition
  • change: particle system: use NSUInteger instead of int for initWithParticleCount

These are the changes affecting the book’s source code. There were some more changes in the cocos2d-iphone engine, for example some actions have been renamed as well.

Good News: Updated Source Code for v1.0

I updated the book’s source code to use cocos2d-iphone v1.0.0 rc2. Once the v1.0 final is released I’ll make another update.

You can get the book’s source code from the Learn Cocos2D Book product page (scroll to the bottom), or via this direct download link. The download is about 100 MB and contains all the chapter’s source code plus some extra projects not mentioned in the book, and all of them (over 70!) are now using cocos2d-iphone v1.0.

Note: This code obviously differs slightly from the code described in the first edition of the Learn Cocos2D book, so you should get the unmodified v0.99.x book source code as well.

Upgrading to Cocos2D v1.0

I also recently wrote a tutorial outlining the steps to update an existing cocos2d-iphone v0.99.x project to v1.0 in case you have an existing project that you’d like to upgrade to the latest Cocos2D version.

Learn Cocos2D: Second Edition

All these changes will be reflected in the second edition of the Learn Cocos2D book.

The second edition will be released summer 2011, likely around July to August. This is my estimate based on the fact that my work is scheduled to be completed on June 27th, and I’m working hard to keep that (tight) schedule.

Actually, make that we are working hard. The second edition of the Learn Cocos2D book will have contributions from a co-author. Someone who is well-known in the Cocos2D community! To be unveiled. :)

Book: Learn Cocos2D 2

On May 26, 2011, in , by Steffen Itterheim

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


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

Tagged with:  

Learn Cocos2D Book 2nd Edition Started

On May 5, 2011, in book, by Steffen Itterheim

Today, after several delays I finally got around to start updating the Learn Cocos2D book to its second edition. The second edition is due to be published in summer, likely in July/August.

I decided I’ll easy myself into it and start by updating the first chapter. There’s no code and relatively little to change. The biggest addition here is the list of popular Cocos2D game engines I wanted to add. Here’s a screenshot of the comparison table I added:

Note: the link to cocos2d should have been http://www.cocos2d.org

The list doesn’t include all of the cocos2d ports, just those that are mature, stable and relatively up-to-date. I also completely removed the paragraph about Section 3.3.1 because that topic fortunately is no longer an issue.

Errata Corrigata

Next I started to go through all of the 108 erratas that were posted on the Apress site. If you’re interested, here’s the errata list as xlsx or as csv file with emails and names of reporters removed.

I knew that there were duplicates but I didn’t expect over 50% of the errata to focus on only two things: the mixed up images 3-1 and 3-2 was by far the most often reported errata. Following that were two packs of spider variables either not being declared or not being initialized in chapter 4. Those led to compile errors in one case and non-dropping spiders in the other - if you were typing in the code straight from the book.

After I had removed all duplicates I was left with 28 unique and usable errata items that I’m going to look into, and 14 of those I was able to fix today.

Once I’m done with those I’ll be going through the painstaking process of updating no less than 72 Xcode projects from cocos2d v0.99.3 to v0.99.5 to cocos2d v1.0. Or maybe I’ll just wait a couple more days for the final v1.0.

Tagged with:  

WOW! :)

On April 14, 2011, in book, cocos2d, by Steffen Itterheim

From the Apress website:

The iPhone-developing Cocos2D crowd beats the .NET afficionados! Kudos and thanks! 😀

Tagged with:  
Page 3 of 712345...Last »