Floaty Balloon: How to Build a Flappy Bird Clone in 2 Hours

Unless you’ve been living under a rock, you’ll have probably heard of a little iOS game called Flappy Bird.

Whilst users went nuts over it, the iOS developer community’s response to Flappy Bird was a bit less enthusiastic; many criticised it for its poor implementation and relative crudeness. But though several developers declared that they could have built Flappy Bird in an hour, others quietly confessed that, although they could see it was simplistic, they actually wouldn’t have the first clue where to begin with writing a game for iOS – even one as simple as Flappy Bird.

Games are a hugely popular genre of app, but making games is a somewhat different process to traditional application development. There are dozens of ways to build games on iOS, from cross-platform tools such as Unity, to 3rd party frameworks such Cocos2D, to built-in APIs such as SpriteKit and GLKit. Most app developers have heard of these, but many have never have tried using them.

In this tutorial, we’ll demystify gaming on iOS by building Flappy Bird Floaty Balloon in a couple of hours, using ordinary UIKit classes that any app developer should already be familiar with. UIKit is not designed for gaming, but as we will demonstrate, it’s perfectly suitable for building a simple game such as this.

Continue reading

NSIndexPath and row method

In working with the SimpledDrillDown example in the iPhone SDK, I was walking through the code in the RootViewController class. The interface definition is shown below:

1
2
3
4
@interface RootViewController:UITableViewController
{
DataController *dataController;
}

There is a method inside the class that looks as follows:

1
2
3
4
5
6
7
- (void)tableView:(UITableView *)tableView
  didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
...
detailViewController.detailItem = [dataController objectInListAtIndex:indexPath.row];
...
}

The last parameter to this method ‘indexPath’ is of type NSIndexPath . Now if you look at the class reference for NSIndexPath , you won’t find the ‘row’ method shown above? What’s up with that?
Continue reading