Cocos2D and UIKit working together

I have been refactoring BocceBeers lately, and as a fan of tools such as Interface Builder, I didn’t have the time to really learn the ins and outs of CocosBuilder, and I already had working gameplay code, so I wouldn’t really need to rebuild the game in CocosBuilder because that would be a make-work project.

What I did need to do is make User Interfaces for the iPad version of the game that I am making.  So I thought, now that I’m an experienced App Developer, can I not just use UIKit and make NIB files?

The answer is yes.  I decided to go about making a general solution (demo project) for any of  you seeking to use UIKit for menu systems, but then leverage the power of Cocos2D for your gameplay.

I also created an asynchronous scene loading class which you can check out as well.

Please check out the demo project on github here.


Indie Game Development and BocceBeers v2.0

Now that I’ve got a bit of down time and am on holiday, I thought I’d dust off the code of my very first software project in my career BocceBeers, and see if I can give it some of the upgrades it’s been screaming for since iOS 3.0.

Refactoring old code is a funny endeavour!  Seeing as BocceBeers was the first thing I ever wrote, completely on my own, not much help other than forums, I’m amazed at 2 things:  That they game runs as well as it does, and how messy the code was!

Basically, I’ve had to majorly rewrite, rename, convert to ARC, ensure better decoupling and encapsulation just to get the game more or less running again.  That was the boring part.  But then it moved on to more interesting things…

My goals for this upgrade are to make it universal and playable on the iPad, adding retina support, and make it possible to have turn-based play over the internet.  If I find time, I will also look into incorporating an instant replay system I had been working on.

(On a cheesy note, I should add that the inspiration to do this now as that I gave my parents an iPad mini recently and back in 2010 when I wrote the original BocceBeers while home at my parents’ on holiday, my mom was my guinea pig game tester.  So now that she has an iPad, the proud mom that she is, asked me: “Can I play your game on this?”  So I thought, I’m gonna improve this game!)

As such, having become more of a UIKit expert than Cocos2D (on which BocceBeers 1.0 is written), I thought I’d rip out all the front end classes implemented in Cocos2D and use UIKit.  This makes it a lot faster to me to write UI Code, and UIKit is really an amazing framework that we all just accept but probably rarely marvel at the technological genius of Apple Engineers.  Now that I’m 3 years more experienced, I’m finding Cocos2D to be a great framework, but there are some oddities about it, just sometimes even down to strange naming conventions.

Anyhow, the whole point of this post is to say I’m loving this job, and I think my true calling in life is probably to be an indie games developer because of the total freedom it allows and it’s highly creative and most importantly fun!  That said, any iOS development has been fun.