Thursday, November 5, 2015

Google Games: Leaderboard + Achievements

I have a weakness in cute things. I often play cute games, telling myself that I do it to "learn about game mechanics". This time, I actually integrated Google Play Games Services due to inspiration from playing!

Alphabear

My latest addiction is Alphabear. You earn bears while playing a word game, which gives you extra powers. They show you the list of bears you have collected:

I want that for Fit Cat! A catalog, if you will, showing all the cats that you have seen. Initially I was going to do the UI and tracking myself, but then I came across Google Games Achievements. Perfect!

Leaderboard

When I started looking into Google Games, I learned about Leaderboards as well, which seems a simpler concept to launch with. I just need to submit the number of steps to Google Games, and everything else is handled for me. Great!

One problem though: Fit Cat is a watch face, and the watch does not have direct internet access. To upload the steps, I transfer the data to the phone using the Wearable Data Layer API and send it to Google Games in a WearableListenerService.

To test that, I needed to pace around the house, because the Data Layer API only syncs when the data changes. If I sit on my chair in front of my computer, the number of steps stays the same, and so I will not get a callback. It was pretty hilarious, me pacing around and rushing back to the computer to check the logs and see if the phone received data.

Placeholder achievements

I was going to publish my game with the leaderboard, but got blocked because Google Games requires at least 5 achievements. This was right before Big Android BBQ, and I did not have a lot of time before flying to Texas. So I added 5 placeholder achievements and made them hidden, and launched.

Actual Achievements

After I launched leaderboard, I wanted to go back to repurpose the hidden achievements to show cats. I want them to be public so that you are motivated to reach a goal level to see a certain cat.

Alas, I cannot switch an achievement from hidden to public once I published them. So I created new achievements for the cats.

While "May appear at 10000 steps" gives people a goal to walk more, "Secret" is just really mean if it is not attainable. I was holding off the launch until I came up with 5 achievements to backfill the placeholders. That took a few days, but I now have some fun ones for people to discover!

Play Games app

The nice thing about integrating with Google Play Games Services is that your game will show up in the Play Games app. Friends can compare achievements with each other, which is really fun.

However, Fit Cat was not showing up, and I was not sure why. Turns out you need to categorize your app as "Game" rather than "Application" on Google Play, so now Fit Cat is a "Sports Game".

Usually you play sports games by tapping your fingers on screen and pretending to be playing sports, but this one you actually play with your feet in real life!

Easy gaming

Google Play Games Services has a lot of built-in UI, making it super easy to add gaming to your app, even for a non-game like Fit Cat. There was a few non-obvious requirements (ahem, minimum 5 achievements), so I'd recommend going through the checklist during planning, not before launch like me.

Overall it's a great enhancement to my app, for very little effort. I hope you like it too!

No comments:

Inline coding questions will not be answered. Instead, ask on StackOverflow and put the link in the comment.

Post a Comment