Tip:
Highlight text to annotate it
X
Hello, and welcome back.
So, in our last lesson, we added this lovely view leaderboards
controller that doesn't show anything,
because we have no leaderboards.
So let's think about adding some.
Now, we have three difficulty levels in our game,
easy, medium and hard.
Probably makes sense for each one have its own leaderboard.
So let's go ahead and do that.
I'm going to pop over to Chrome here, and trick this a bit.
And I'm going to go to play.google.com/apps/publish,
the developer console, and check out our game services.
And let's go in to Guess My Number.
So we can go into a leaderboards.
and the process here is fairly similar to adding achievements.
We fill out all the various information
that we need in a form.
And then the system generates a unique ID for us
that we can use later to refer to this leaderboard.
So let's do that.
I'm going to click on Add Leaderboard.
And for this one, our name is going to be Easy.
And this will be the leaderboard for an easy difficulty level.
We have some options for score formatting.
It can be numeric, which would be
like an integer, or a floating point.
We also have options for currency and time.
And maybe if we wanted to do a fastest
time to guess the answer type of leaderboard,
we can use time for that.
We have an icon.
This is optional.
I do recommend using icons if you want to create, say,
actual games that you want people to download and buy.
The reason is that in the Play Game standalone application,
your leaderboard icons do show up fairly prominently.
Someone looks at your game, one of the three screens
that they're going to see about your game
are going to be your leaderboards.
And in those cases, it's nice to have leaderboard
icons that look interesting.
In our case, we're going to stick with the default
leaderboard icon, as provided by Play Game Services, which
is like a little crown thing.
Ordering here, we can choose whether larger
is better, or smaller is better.
In this case, our leaderboard is going
to be based on the number of guesses.
So how many guesses did it take to get the magic number?
So in this case, smaller is better.
I do want to take a moment to add,
this is my favorite feature of this developer console.
Rather than having ascending or descending,
and then you have to stop and think, well
what does that actually mean?
Like, smaller is better.
So much clearer.
Love it.
Anyway, then we have limits, and these are basically
the upper and lower bounds of any score that
gets submitted to this leaderboard.
So I suppose we want to say that we don't
want to allow scores lower than one.
Makes sense.
You can't actually make a guess in zero guesses.
And maybe for the small leaderboard, we want to say,
you know what, let's not allow scores greater than 100.
In theory, someone could make the same wrong guess
over and over and over and over again,
and maybe our players are going to have
some fun, perverse, hey, let's see who can get the worst
score in our Guess Our Number game contest.
Maybe that's something you want to encourage your players
to do, but in my case, I'm going to say, no,
let's not encourage that behavior.
We're just going to cap our lower bounds, or, I
guess our upper bounds here, at 100.
And list order means that if you were
to view your leaderboards, where would this appear on the list?
And we'll have it appear first.
So there we go, this is done.
I'm going to hit Save and add another leaderboard.
We'll create another one for medium.
This should be pretty easy.
Smaller is better, and let's allow scores of 1 and 1,000.
Save and add another leaderboard,
and hard, smaller is better, and 1 and 10,000.
Let's save.
And we're done, look at that.
We've got three leaderboards.
We have unique IDs associated with each one of them.
And they should be ready to publish.
We've actually done everything we
need to do to get a leaderboard into our game.
So let's go back to our application and try it out.
If I were to hit leaderboards right now, I'd probably-- yeah,
I'd get the cached version.
So one quick way to fix this would
be to sign out and sign back in, or you could just stop, and run
our application again.
And now it'll kind of force our game
to go out and grab the latest data.
So now when I click leaderboards,
I now have three entries, easy, medium and hard.
Now, if I were to click on this easy one,
I'm taken to my individual leaderboard, where
I can see entries for public submissions
this leaderboard, and anybody from my circles
that has submitted a score to this leaderboard.
In this case, this is a brand new leaderboard,
nobody has submitted anything, so all these entries are blank.
That's kind of too bad and kind of boring.
But that's OK because in the next lesson,
we'll start submitting scores to these leaderboards.
So stay tuned, and I'll see you soon.