In Depth iOS & Cocos2D Performance Analysis with Test Project

On November 17, 2011, in idevblogaday, by Steffen Itterheim

I took Mike Ash’s performance measuring code from 2008 with the improvements made by Stuart Carnie in early 2010 and turned that into a performance measuring project for 2012.

I know it’s still 2011, consider this a forward-looking statement. In any case, the test project is available for download, ready to run, includes Cocos2D v1.0.1 and is relatively easy to modify for your own needs. This project is also available on my github repository where I host all of the iDevBlogADay source code.

Since numbers are so dry and hard to assess, you’ll find the rest of this post garnered with charts and conclusions based on the results obtained from iPhone 3G, iPod 4 and iPad.

Continue reading »

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. :)