The aim of the game is simple – to tap all the numbers from 1 to 25 in sequence, in the fastest possible time.
This app is actually a great starting point for developing an Android game. While the concept is simple, this implementation makes use of custom views, UI themes, threading, and integration of a third-party high score system. It has several activities, and involves basic application life-cycle management (especially handling the threads).
The menu is quite simple, although the custom theme ads a little visual interest. Notice also the AdMob graphic embedded at the bottom of the screen. In this case it’s showing a house ad, but normally a paid advertisement would be shown here.
The obvious menu entries are present – New Game and High Scores. We’ll look at these in more detail a little later. The other menu options are quite straightforward:
About – Launches the Android Market page for this app
Feedback – Opens a blank email addressed to the developer (that’s me)
Quit – Closes the program
When you select New Game, a countdown timer begins, allowing 5 seconds to prepare for the game. As soon as the 5 seconds expire, the game board appears with 25 tiles and a timer begins counting up. This is accomplished through two separate threads, and the Android Message framework to enable asynchronous UI updates between the threads (If this doesn’t mean anything to you, keep an eye out for some upcoming tutorials on the subject).
When the appropriate sequential number is tapped, that tile will disappear and an on-screen cue will indicate the next number to be tapped. Once all the numbers have been tapped, the timer thread stops and the high score is calculated.
For this app, I used the ScoreNinja high score library. This was really easy to integrate (once I learned that passing “-1” as the current score would show the global dialog) and works quite well. In future I’ll probably use a larger library such as ScoreLoop and integrate some more social features, but ScoreNinja works well for this particular app.
Since it doesn’t make sense to use the completion time as the user’s high score, I calculated the high score using a simple formula so that rankings would appear correctly in the global list. What formula exactly? I’ll leave that as an exercise for you! (Hint: try completing a game in 100 seconds)
So there you have it – my first Android App. There are still plenty of features that could be added, but all the fundamentals are there. Feel free to download it and let me know what you think. Any feedback, positive or negative would be greatly appreciated. In the upcoming weeks I’ll be posting some tutorials and sample code based on what I learned from developing this app, so let me know if there’s anything you would like to learn about. Also, stay tuned for download stats from the Android Market as they come in.