Thursday, October 22, 2009

porting BarNiteBingo to Android

After we got BarNiteBingo for the iPhone done, and into beta testing, I sat down to see what it would take to port the game to Android. Being a java developer for over ten years, and having written one simple Android app before (to read exchange email) I didn't think this would be too difficult.

BarNiteBingo is certainly not the most complicated game, and it has primarily one screen that takes most of the work, with the other screens being settings and help screens, along with a splash screen. Converting the actual game play code was very easy, I could literally copy and paste the methods in Objective C into the java classes, and translate the code. Most of the data structures and all of the code was pretty easy to translate between two object oriented languages.

Having all the graphic and sound assets already done, and the screen layout already decided made it pretty easy to handle that in Android as well. I did use the AbsoluteLayout, which is now deprecated, and if we get any traction on Android, I'll probably go back and do a RelativeLayout for the app, and make sure it will layout properly on multiple screen sizes as well. But for now, we've got a pretty much identical version on the android supporting the 480x640 layout that the G1 and myTouch have, which currently represent most of the handsets (even though there are MANY new handsets coming out by the end of year).

The biggest task in porting to Android turned out to be embracing the Android way, and using it's idioms instead of the iPhone idioms. One of the major changes that I ended up having to deal with was supporting the back button on the Android devices. On the iPhone when we went to the settings or help screens (or even the Win screen) we always needed to provide a button to get back to the game screen.

With Android you certainly can provide a button, but it's not common. Android keeps a stack of views, across applications. So if you want to get to the view you came from, you just hit the back button. The beauty of this system is you can send the user to a web page, or an email compose activity and when they're done and that view pops off the stack (or they use their back button) they come back to your app, there isn't anything you have to do in code to make that happen. This keeps you from re-inventing system tasks all the time to keep the user from leaving you application.

I really like both platforms, and I think we'll continue to support both as long as it's easy to do, and there is some amount of sales on the Android side. As the number of devices and carriers increase, it seems logical that the Android Market will pick up some steam. The iPhone App Store does have an incredible head start though, so only time will tell.

No comments:

Post a Comment