Monday, March 1, 2010

Tic-Tac-Toe Update

In Chapter 9 of More iPhone Development, we showed you how to add online play to program that already used GameKit to do network communication over Bluetooth. The code in that chapter is still correct, but the appearance of the online peer picker in the game always bothered me, since it was so different from that of GameKit's peer picker:

before.png

After writing up the technique in my last blog posting, I realized that I could use the same approach to make the appearance of the online peer picker more closely match the GameKit peer picker.

I haven't gotten it pixel perfect, and the code isn't written in such a way that you can just drop it into another project and use it (though I plan to do that at some point), I though some of you might be interested in seeing my progress, as well as seeing how the dialog presented earlier can be used in more complex scenarios.

Here is the current state of things:

after.png

As you can see from the screenshot, there are some differences in the size and placement of the views, and the translucency of the button. Plus, the background image doesn't dim in my version yet. But the overall appearance is much closer, and without the benefit of a side-by-side comparison, you'd be hard pressed to notice the difference. I plan on tweaking it a little, though it may be impossible to get a pixel-perfect match without using private APIs.

You can find the current version of the TicTacToe project right here. I'll also add it to the iPhone Bits repository on Google Code when I get a chance. Be forewarned that this is still a work in progress and the code is a little sloppier than what I normally place out here. All the functionality for the new peer browser is in TicTacToeViewController rather than in its own class, where it should be.

No comments:

Post a Comment