Our DNA is written in Objective-C

I’m a Game Studio!

Until today I had only every tried my hands on a UIKit-based game, a clone of the Wheel of Fortune game show. Unfortunately Sony Entertainment asked Apple to ban this from the app store. So I had to take it offline.

Whenever an independent game developer had a success I would feel jealousy boil up in my stomach. If only I could also make games. But I was too busy mastering Objective-C and Apple’s frameworks (on iOS and Mac) to be able to devote time to learning Cocos2D.

This has entirely changed last week, when Apple announced the new Sprite Kit framework.

BSA Banner

After viewing the two sessions from WWDC 2013 dealing with the new framework I felt ready to try my hands at something easy. I thought about doing a Newton’s gradle or a Flipper, but then my mind got stuck on the very first physics-based game I ever played: Lunar Lander.

This was a coin operated game which was a big hit in arcades. Yes those where the times before there were any consoles to play at home.

Game Making Experiment

I wanted to see what I could whip together in a day being a total newbie when it comes to game frameworks. So I took the lunar lander idea and googled for some inspiration. I found a couple of nice images to serve as my “programmer art”, which I treated with Pixelmator.

The Lander

When it came to tell the physics model about the outline about the vehicle I found myself drawing the outline shape with PaintCode, which helped me find the coordinates of the points that span up the shape.

Which reminds me that a long time ago I had suggested to the makers of PaintCode to have a Quartz output mode. Exactly for this kind of scenarios where you don’t want to go to the higher level NSBezierPath or UIBezierPath but stay on common ground.

I was stumped at first, because apparently having more than 12 points in the shape would cause an exception. But that got cleared up quickly by a helpful friend on the Apple developer forum.


Since the shape would need to be a CGPath to be working on iOS and Mac alike I opted to create the path in code from the points I had found.

- (CGPathRef)newPhysicsOutlinePathForScale:(CGFloat)scale
	CGSize textureSize = self.texture.size;
	CGSize scaledSize = self.size;

	CGFloat factor = scaledSize.width / textureSize.width;

	CGMutablePathRef mutablePath = CGPathCreateMutable();
	CGAffineTransform transform = CGAffineTransformMakeTranslation(-scaledSize.width/2.0, -scaledSize.height/2.0);
	CGPathMoveToPoint(mutablePath, &transform, 197*factor, 286.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 172.5*factor, 295.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 88.5*factor, 251.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 8.5*factor, 26.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 32.5*factor, 21.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 337.5*factor, 20.5*factor);

	CGPathAddLineToPoint(mutablePath, &transform, 348.5*factor, 26.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 264.5*factor, 191.5*factor);
	CGPathAddLineToPoint(mutablePath, &transform, 232.5*factor, 248.5*factor);


	return mutablePath;

Note the transform which lets me use the points as PaintCode told me, even though the origin of the path is supposed to be in the center of the object. The factor is necessary to update the physics body if the scale of the object is modified.

A full tutorial will have to wait until the fall. But I think I am not breaching the NDA if I show off my result at the end of the day.

There is still a ton of work missing if this is to become a full game: fuel consumption, uneven terrain, dying through crashing or leaving the screen and so much more. But finishing the game was not the point of this exercise.


I find that having an Objective-C based gaming framework helps us to get an extremely fast start. And even a gaming n00b like myself can produce impressive results in very short time. This move is probably going to be one of the smartest strategic decisions that Apple revealed at this year’s WWDC. Tearing down all barriers to entry for budding developers of 2D games like this strengthens the Apple platforms like few other moves could.

Of course just having a powerful framework does not a Game Studio make. You need to have a pro do the game design, make the artwork, take care of the sounds. Making successful games usually is a team effort nowadays. But let me say that Apple is reducing the friction like stepping on a bar of soap in the shower.

Can you imagine yourself taking up a new hobby? Maybe something related to making 2D games? Now I can!

Categories: Apple


  1. SpriteKit’s API is very similar to Cocos2D, by the way. It’s basically Cocos2D-lite.


  1. Sprite Kit turns anyone into Game Developers | Kobold Kit
  2. The Impact Of Sprite Kit On The Economy | Learn & Master Cocos2D Game Development

Leave a Comment

%d bloggers like this: