gc.jpeg

What’s all this fuss about Game Center then? Apple says:

“Experience social gaming on your iPhone. Find friends or use auto-match to play multiplayer games against new opponents. Track achievements and compare high scores.”

But we already have that, right? Yes, in various forms since early 2009. There’s OpenFeint, AGON Online, Scoreloop, Plus+, and many others. How is Game Center different? Well, aside from the 800 lb. gorilla in the room (iAd, anyone?), Game Center is a system service that comes installed on most versions of iOS 4.1.  This reduces the amount of code your applications need to build with, and in theory simplifies the integration process. More on that later. This is not a tutorial, however, just a short ramble about my experience setting up a couple of games to use Game Center.

Sure, v1.0 of Game Center is a baby step, and there are/will be glitches. Yes, Apple has a lot of catching up to do. But they are already way ahead in some ways. A very large base of potential users with a pretty low barrier to adoption. Support for all languages used by iOS 4.1. I like to focus on that point, because two of my games are translated into 13 languages. My apps were translated before the existing online services were available, and when they came out they only supported English at first.

I decided it would not be acceptable to put in non-translated global scores and achievements, so I took a pass on online scores entirely. For reMovem free I initially posted (by hand) top scores to a web page, after soliciting users to send in screen grabs of their weekly scores. This sort of spiraled out of control and I stopped advertising the link to the high scores web page (sorry).

By the time I got around to doing a couple of holiday games, about a year ago, I settled on AGON Online as my online leaderboard service. Integration was fairly simple, and Daniel and the rest of the staff are as good as they come. Working with them truly was a pleasure. Even so, I was just looking for an English solution at the time. AGON has teamed with some great developers, and they have great games, but there’s still only a couple hundred titles. Adoption rate for me was pretty low, and I begun to wonder if it was worthwhile.

Earlier this year I added support for OpenFeint to reMovem 2. They’re the grand-daddy of online services, at least in iPhone terms. They have probably got thousands of games and developers and upwards of 30 million players. That brings a boatload of users to the table, but, again it’s only English. I haven’t translated reMovem 2 so that’s OK. Adoption of OpenFeint inside reMovem 2 is slightly higher, but it’s still about 1 in 5. OpenFeint is poised to be a gamer’s portal on the iPhone, and very soon Android too. It appears that Game Center will compete with OpenFeint, but there’s talk of some sort of interoperability from the OpenFeint side. We’ll see.

Even though I’m keen on Game Center’s language support, Apple’s done a disservice to the millions of iPhone 3G owners who can’t participate in the fun. For unknown reasons, Game Center support is limited to iPhone 4, iPhone 3GS, and iPod touch (and generation and later). This is great news for iPod owners, though, which makes sense since Apple’s pushed the iPod as a great game device. The decision to not support the iPhone 3G is no surprise to developers, but the media made much hay with this last week, which just begs the question: Why?

russian-gc.jpeg

As with iAd, Apple has high hopes for Game Center. I’m certain it will be around next year. So I’m comfortable finally adding online scores to reMovem (and hopefully reMovem free), knowing that the users won’t have to have a partially-translated interface.

Technically, Game Center is part of Game Kit, which has been around since iOS 3.0. The Game Kit framework also provides peer-to-peer connectivity and in-game voice. Game Center debuted in beta versions of iOS 4.0, but only as a developer preview. Game Center itself provides functionality for leaderboards, achievements, and multiplayer game discovery. Earlier this summer Apple announce the September 8th launch date, and the rush was on to get games submitted with Game Center features.

I’d been eager to add Game Center to reMovem since it was announced. Developers are excited because Game Center uses a concept called blocks for most of the asynchronous callbacks. Blocks are available in iOS 4 and later and OS X 10.6 and later. Objective-C and Cocoa make it easy to mix code that requires iOS 4 and older code, for example, so your single binary can run on iOS 3.1.3, 3.2.2, 4.0.2, and 4.1. Weak-linking the Game Kit framework allows you to target older devices and OSes. Unless of course your game requires Game Center to function at all (i.e. multiplayer).

I added leaderboards for reMovem’s four modes. It’s easy enough to know where to make the appropriate calls to add values to the leaderboard. The problem is that almost everything in Game Center is asynchronous. Because there is no offline support (a major deficiency, in my opinion), you must detect and retry score submissions. This is the typical pattern to report a score:

- (void) reportScore: (int64_t) score forCategory: (NSString*) category {

    GKScore* scoreReporter = [[[GKScore alloc] initWithCategory:category] autorelease];

    scoreReporter.value = score;

    [scoreReporter reportScoreWithCompletionHandler:^(NSError *error) {

        if (error != nil) {

            NSData* scoreReporterAsData = [NSKeyedArchiver archivedDataWithRootObject:scoreReporter];

            [self reportScoreLater:scoreReporterAsData];

        }

    }];

}

Note the block object (begins with ^) which detects the error and calls [self reportScoreLater:scoreReporterAsData]. That’s where the fun begins. You can implement this any way you see fit: add it to a Core Data store, or push it onto an NSArray, or into an SQLlite database, and attempt to re-submit again later. It’s clear Apple expects you to persist this information and retry even after quitting the app and relaunching. The exact same situation exists for achievements. Both are begging for a standard offline implementation, the way all other services operate.

sign-in-gc.jpeg

One other funky thing to deal with is the whole authentication issue. It’s seriously complicated by the multitasking devices, because a player can be “signed in” when they start a session, then switch to Game Center and sign out, then switch back to your game, etc. There are notifications you can register for to detect authentication changes, but the UI to sign in within a game is weak, and offers no option to customize. Besides, there’s no standard UI to allow users to enable or disable Game Center features, so it’s unclear how you’d even let them do so. If they cancel the authentication once in a session, does that mean for all time? I have no idea. What if they change their minds later and want Game Center features? Again, unclear. I opted to add a switch on the Info options screen which simply says “Game Center.” If the user puts the switch “On” I will attempt to authenticate them whenever necessary. This has been in the App Store for about a week now and I’ve had a few players complain that they can’t turn it off. I’m pretty sure they are just not exiting the app completely (a whole other blog post!) on iPhone 4 or iPhone 3GS.

Finally there is the fun of using iTunesConnect to setup the whole Game Center configuration for your application. This is not difficult, and the documentation is fairly accurate and complete, but there are many scary areas which warn “once your application is live this cannot be changed”, etc. If you’ve worked with In-App Purchase you’ll be familiar with the whole concept of working within a developer “sandbox.” Game Center adds new pain to that experience, but at least it works fully in the simulator. Before September 8 Game Center only ran in a sandbox, but since launch it’s way too easy to get confused about whether your device is signed in to the real service or the developer (sandbox) service. An impractical solution would be to dedicate several (one simply won’t do) devices to testing your sandbox builds. I struggle with this throughout the day.

It would be nice to be able to reset player scores and achievements. I’m hoping iOS 4.2 (promised for Fall) will address this and a couple of my other gripes. We haven’t seen the beta for 4.2 yet, so it’s too soon to say. I do fully expect this service to improve rapidly as Apple learns from the launch of Game Center. Have you implemented Game Center yet? If so, what has your experience been like? Comments welcome.