There are many Cocos2D + Storyboard tutorials, it’s about time to do another one that’s done right. Also, this one’s backwards: we’ll start with a Cocos2D template and then add Storyboards to it. The tutorial will work for existing Cocos2D projects to which you wish to add Storyboards, too!
I’ll show you how to add Storyboards to a Cocos2D v2.1 project, with ARC enabled of course. This approach will take a little more work, but the solution will be complete and you gain a fair understanding of how things work together. Plus two custom but reusable View and Navigation controller classes, and I’ll show you what changes you need to make to the AppDelegate.
The resulting project will work with iOS 5 and iOS 6 and autorotation. The navigation and cocos view controllers are separated, and you will be able to subclass them for code customizations as is customary in Cocoa. Cool? Cool, cool, cool!
As usual you can grab the example project (Cocos2D + Box2D + Storyboards with ARC enabled) from github. I’ll also be adding a Storyboards template project to KoboldTouch in the next update, and document what’s special about the KoboldTouch solution.
Oh, only one thing … this tutorial is part of Essential Cocos2D. Head on over and enjoy!
Or so goes the argument. Still.
I wish Apple would just pull the plug and completely remove MRC support from LLVM. I’m getting tired, annoyed and sometimes angry when I browse stackoverflow.com and frequently find MRC code samples containing one or more blatant memory management issues.
Before I rant any further, this article is about testing the performance difference of ARC vs MRC code. I provide some examples, and the updated performance measurement project I’ve used before for cocos2d performance analysis, and the results of the full run at the bottom. I also split it into both synthetic low-level tests and closer to real-world algorithms to prove not one but two points:
ARC is generally faster, and ARC can indeed be slower – but that’s no reason to dismiss it altogether.
Measuring & Comparing Objective-C ARC vs MRC performance
Without further ado, here are the results of the low-level MRC vs ARC performance tests, obtained from an iPod touch 5th generation with compiler optimizations enabled (release build): Continue reading »
Continue reading »
This year’s Line-Drawing Game Starter Kit Xmas sale starts early and runs for two months until January 7th, 2013. You can have it for $49.50 instead of $99 – 50% off!
But there’s a catch: the XMAS2012 coupon code has only 100 uses! Act fast before it’s used up.
Site License! Unlimited Apps!
Royalty Free! No Attribution!
60 day money-back guarantee!
Made with the popular cocos2d-iphone game engine.
Compatible with cocos2d-iphone v1.1 and v2.0, and iOS 6.
Includes ARC enabled versions of the starterkit!
XMAS Sale – 50% off – only $49.50
Enter: XMAS2012 as coupon code.
Coupon code limited to 100 uses. Act now!
It’s only a start to better explain how KoboldTouch compares with cocos2d-iphone.
I’m now working on a KoboldTouch mini-game to showcase the KoboldTouch workflow and features. It’ll be the basis for the KoboldTouch Introduction Tutorial.
I’ll post a video presentation of the project and key points once it’s done. If you’re interested you can follow KoboldTouch development via PivotalTracker.
The mini-game project is also very important to “eat my own dogfood”. Even just a simple game made several things that didn’t feel right obvious, and presents opportunities for improvement.
I’m happy that the KoboldTouch users requested this simple game tutorial.
Speaking of members: leaving aside the initial 2-day launch rush, on average two new members sign up every day.
If KoboldTouch continues to grow at this rate, it will have 100 members before Xmas! That would be a major milestone I did not expect to achieve before February/March!
You can help KoboldTouch by taking 5 minutes of your time to complete the Cocos2D Developer Survey. I’ll post the results in a week and what they mean for KoboldTouch.
Here’s what I’m working on. Hopefully this answers the questions I’ve been getting, in particular those about KoboldScript. And what’s happening with it, when is it coming, when can we stop using Corona SDK, etc.
Well then, let’s start with …
Well, the short answer is: KoboldTouch is an MVC wrapper around Cocos2D.
The long answer … let me start by saying that Cocos2D is suboptimal. From a code architecture point of view. Cocos2D has no concept of structure besides views (nodes), and doesn’t encourage structure in your own code. It happily lets users subclass views in order to add data and game logic.
I can’t stop but feel helpless to see beginners learning the things we’ve abandoned 20 years ago as bad practice. Yet Cocos2D code is written by subclassing views as if it were the most natural thing to do. It’s also the very thing Apple tells you not to do.
The result are projects lacking in what is called separation of concerns. It’s not just about experience. Without a clear architectural model frequently reminding you to consider separation of concerns, anyone is more likely to end up creating a blend of design patterns at best, or worse:
… but not quite out yet. If you can’t wait until August 29 you can always buy the Alpha eBook version now (as PDF) and receive the final eBook version for free (as PDF, ePUB and MOBI) when it’s available.
I’ve updated the book’s product page and included links where you can download the source code for the 3rd edition.
Learn cocos2d 2 (Third Edition)
Release Date: August 29, 2012
Cocos2D v2.0 is used throughout the book. To my knowledge this makes the Learn Cocos2D 2 book the first book to cover cocos2d-iphone v2.0.
ARC (automatic reference counting) is used exclusively in the book. All descriptions and source code projects have been updated to ARC, and 12 Cocos2D ARC-enabled Template Projects are included in the source code download. The book contains a description on how to enable ARC in a cocos2d project. Working with ARC means having to write and learn less code while being able to write faster code with fewer bugs. Win, win, win.
You can now also follow the book while using Kobold2D. Any differences between cocos2d v2.0 and Kobold2D v2.0 are explicitly mentioned in the book. In fact, you’ll have to work through less text and code if you use Kobold2D.
The book’s source code is compatible with Xcode 4.4, Mac OS X 10.8 Mountain Lion and iOS 6. It is of course also tested to work with Xcode 4.3, Mac OS X 10.7 Lion and iOS 5.
Learn more about the Learn Cocos2D 2 book here.
Therefore I decided to enable ARC in all twelve standard cocos2d Xcode project templates for both cocos2d versions (v1.1 and v2.0), both platforms (iOS and Mac OS), both physics engines (Box2D and Chipmunk) and publish them on github.
Kobold2D v1.1.1 has been updated to include the latest version of cocos2d-iphone v1.1 (beta2b) from May 3rd this year. This version supports the -ipad and -ipadhd suffixes.
Both Kobold2D v1.1.1 and v2.0.1 have been updated to include the latest Chipmunk v6.1.1 and Chipmunk SpaceManager v0.1.3. Although unfortunately SpaceManager still isn’t fully compatible with cocos2d-iphone 2.0 because it still won’t rotate the sprites.
Again both versions include an important fix for KKInput: I’ve received several reports where users complained that KKInput is missing some events. Specifically the “ThisFrame” variants were prone to never fire. This is now fixed.
Line-Drawing Game Starterkit: ARC + cocos2d v1.1 & v2.0
While I’ve been meddling with Kobold2D updates I found this to be the perfect opportunity to update the Line-Drawing Game Starterkit as well. You now get four versions of the project, two are using cocos2d-iphone v1.1 and the other two have been updated to work with cocos2d-iphone v2.0.
And each of the two cocos2d-iphone version projects allows you to choose between the ARC enabled project or the classic manual reference counting project. The included readme document explains this in greater detail. Suffice it to say you can simply choose with which to start: cocos2d v1.1 or v2.0 and either with ARC enabled or manual reference counting.
Of course I strongly recommend the cocos2d-iphone v2.0 version with ARC enabled, seeing how the old devices have an ever diminishing, probably below 15% market share.
If you’re an existing customer, you should have received an update email with your download link.