Tuesday, July 26, 2011

Mac Attack...

I have not created a blog entry in some time, for the last 2 months or so all my weekends and evenings have been spent on my latest addiction, iPhone development.

A couple months back I spent some time deciding what programming language to learn, blogged about it here. At the time I based on Tiobe, job stats, current interest and not taking the final step to actually buy a Mac, I choose C#. I spent a couple weeks messing with it, nothing serious, started a WPF clone for one of my favorite tools of all time. Baretail, but it just didn't catch my imagination, so I lacked the drive to finish.

I then got my iPhone, and that was all she wrote... I was hooked, coming from a lame excuse of a "smart phone" The HTC-Touch-Diamond-2-windows-mobile-thing, to the iPhone was a wonderful experience. It didn't take long before I could not resist the desire to program of my new toy... off to the iStore, out with the credit card, returning triumphantly with a single box, (iMac i5 quadcore 4gb 21.5"), inside the box there is a single cable, plug in the power... (spend a couple minutes looking for the on switch)... basic OS config, user and such.... done.

I had heard something about xCode, off go App Store... wait a day for the monster 4.5gb download. Stumble around hello world, and 2 or 3 other tutorials and that was that. I was hooked and with that 2 months of weekends and evenings were lost infront of the iMac. This last weekend my wife and I eventually submitted the game, and now we have to wait for probably 2 nerve wracking weeks for approval or rejection.

I'll will discuss more specific details once it is released but For now I'll share some experiences and thoughts from the last 2 months.

Objective C
I have to say, I like the language although coming for a Java / .Net background some of the intricacies of the syntax, lack of type enforcement and actually having to do your own memory management can be a little tedious when starting.
All that aside but both my wife (a C# developer) and I (Java) didn't feel too uncomfortable picking it up.

Open Source and Other resources
No. 1 most useful thing I found when writing a game for an iOS platform is:
Cocos2D
These guys have done an awesome job, and there is a decent size community / forum to help out if you do get stuck.
I haven't looked at Sparrow as I only found it a couple days after implementing Cocos2D and decided to stick with that. Another blogger did a comparison here.

Physics Engines, there are a couple out there, I figured I would gave it a skip for the first app, there would be enough to worry about without having to learn one of them either.
The 2 Main contenders I can see are:
Chipmunk
Box2D

XCode 4...
ouch, XCode just feels behind the likes of Eclipse, Visual Studio and IntelliJ. Little things we take for granted, are really missed. I am not going to go into the details, just know if you already use Eclipse, Visual Studio (with Resharper) or IntelliJ and start with XCode, you are going to be a little frustrated. To be fair, some of the frustrations were probably from a lack knowledge on my part and to top it off never having coded in the language before.

After submitting my app I decided to try App Code and loved it straight away. It's still in "beta", but using AppCode after coming from IntelliJ fells very natural. So thankfully there will be a real alternative once they release it officially.

General
I will try post useful Objective C/Game/Apple code and examples as I learn. The first 2 quick things to start with:

1. When Using Cocos2D.... and trying to incorporate UIScrollView from the SDK, prepare yourself for some pain. The CCScrollLayer however, is completely painless. We extended it and completely customized it to our game look and feel, it was very simple to do.

2. If you want to sort an array of integers in descending order use a NSSortDescriptor, very hand class actually:

Popular Posts

Followers