Graphics, Media, and Games • iOS • 56:21
Players, Scores, and Achievements are at the core of the Game Center experience. See how these ideas are expressed in the Game Kit framework and understand how your users will interact with your Game Center enabled app. Understand the process of authenticating a player, updating leaderboards, and managing achievements. Learn from a variety of usage scenarios that can help you enrich your game and keep bringing your players back for more.
Speakers: Jordan Ceccarelli, Alex Finlayson
Unlisted on Apple Developer site
Downloads from Apple
Transcript
This transcript was generated using Whisper, it has known transcription errors. We are working on an improved version.
Good morning and welcome to Working with Game Center. My name is Alex Finlayson and I'm going to go over everything you need to know to include Game Center within your game. Game Center is a great tool for you as a developer and offers you so much. We offer great opportunities for you to get visibility with your potential players.
When I look at my friends list, one Game Center, and I see that all my friends are playing your new game, I think to myself, why don't I know about this game? And now from within Game Center, I can click on your application and buy it from within the application. We also offer features such as game recommendations, and we have a store page within the App Store. We have a lot of great features that really allow you to engage your players. We do this with leaderboards and achievements.
The Game Kit framework that we include within Game Center is really easy to use, but extremely powerful. And most importantly, it creates a better gaming experience for your players. Now, like I said, today I'm going to go over everything you need to do to include Game Center within your game, including going over some of the basic features that you need.
And then I'm going to go over some of the more advanced features and some of the new features that we're including within iOS 5. And I'm going to do this by showing you a demo app that we've created specifically for these sessions. Something that we're calling Rochambeau, Return of Rock, Paper, Scissors. And today, I'll show you how to add Game Center.
So there are four topics that I'm going to talk about today. The first is how to get you set up, how to get your game ready for Game Center. This includes going over iTunes Connect and then getting your player authenticated. Next, I'll go over leaderboards. Everything you need to do to get these ready for your app, including defining them on iTunes Connect, submitting them, and presenting them to your user.
The third topic, I'll go over achievements. Achievements are really great. They're a fantastic feature that you get to use to reward your players for what they've done within your game. And lastly, I'll go over customization. This is how you get to use Game Center to work to your look and feel. So with that, let's get started. The first topic I'm going to go over is how to get yourself set up.
Like I've said, there's two things you need to do to do this. First, you're going to want to set yourself up with iTunes Connect. This is a little different than what you do with most applications because you need to get the Game Center servers ready for your application. Second, we'll go over player authentication.
So like I said, when you set up a Game Center game, you're going to have to register your game with the Game Center services. That means that you have to have your game set up within iTunes Connect at the beginning of the development process, not the end. So once you've done that, and this is a well-known process that has lots of documentation, so I'm not going to go over all of it, you will end up at a page such as this. This is what we have for Rochambeau. What we'll want to do is we're going to want to click on the Manage in App. It's supposed to be Managing Game Center. And what we do there is we will come to a page like this.
All we need to do is click the Enable button. Once we do that, we are now set up. You'll notice here, this is where we're going to want to set up leaderboards and achievements. We'll talk about that in just a little bit, but this is the page that we'll do it in.
Now that we have the Game Center services ready for our game, let's go into player authentication. This is necessary at the launch of your application so that you can get your players ready for using your features using the Game Center features. And this identifies the player so that you can use the features such as leaderboards, achievements, Your friend list, multiplayer, and voice chat. We cover everything you need to do to authenticate your player.
And so when a player first looks at your game, as you see here with Roshan and Bo, and they've never used Game Center, they're going to see this pop up. And they'll have three choices. If they have, for instance, created an account in the past, they'll have an opportunity to re-login with this user. They'll also have an opportunity to create a new account. Let's go over what this looks like.
Right from within your game, our sheet will come up and allow them to create an account. They don't have to leave the app or do anything. If they choose, they can also opt out of Game Center, and that means they don't have to do anything else. And by doing so, this will pop up, and they should be able to play your game without Game Center. But in most cases, This will pop up. And that means that they've been logged in and everything will continue on forward. Like I've said, authentication is required for you to use these features, so you want to do this as soon as your game starts up.
There are three things that you need to do to authenticate your user. The first, you're going to want to check to see if Game Center support is available. We released Game Center in version 4.1, so you're going to want to check to make sure that that is the release of the OS that they're using. Second, we're going to want to request authentication. And last, we'll check the results. Let's take a look at what this looks like in code.
As you see here, we're first going to want to check to see the GK Local Player class is available to us. Next, we'll check the OS version, make sure that we're at least on version 4.1. After we've done this, now we're going to have to authenticate the user. We do this using a method called authenticateWithCompletionHandler. This is within the GKE Local Player class.
Once we do this, we're going to submit a block. This block is where we check to see if we've authenticated or not. This is a little different than you might expect because we get this error variable back. But actually, we just want to check to see if the player's authenticated. The reason for this is that your player might have already logged in. And even though that there is a communication error or something else has happened, the player could be authenticated and you want to continue on with Game Center features.
And that's where we do it right here. The last thing I want to mention about this piece of code is that we're going to call it within application didFinishLaunchingWithOptions. And the reason for this is that during multitasking scenarios, we really don't want you to re-authenticate. That is because we do it for you.
We retain your completion handler throughout the runtime of the application. So that means you're going to want to do everything within that block. including checking for new players. So if I were to be playing a game, let's say your new game, and I'm doing really well, and my friend's like, "Hey, what is that?" I'm like, "Here, how about you give it a try?" He then takes a look at it, he's like, "Actually, let me sign into my Game Center account." He does that, and then brings it back up. He doesn't wanna play my session, so that means I'm gonna have to do the right thing, save my game state, and that should happen when you leave the application, and then create a new session when I notice a new player has logged in.
The last thing I want to talk about with authentication is you want to avoid using enable Game Center buttons. And the reason for, our whole API does not really handle this well. And that's because your users probably have already logged into a Game Center. Or if in the rare case that they've opted out, they've already done this.
So when you bring up a confusing dialog box saying, do you want to enable it? Well, they've already made their choice. Why are you giving them another one? So with that, we're now Game Center enabled. And now, Roshan Boat is ready for our other features. So let's continue on. Our next topic is leaderboards. Leaderboards are really great. They are a list of all your players' top scores, and you get to define what they are.
They can be most wins, best time, best level, most kills, anything. You get to define it. Within Roshambo, we have most wins and we're doing it for all three: rock, paper, and scissors. But we also have fastest time because this is a variant of rock, paper, scissors. This really will engage your user and make them want to come back for more.
And it really encourages competition. When I get to look at my list of friends on Game Center and I see that someone has just beat the top score that I spent all night working on and even missed a bunch of sleep because I was so addicted to this new game, I'm going to be disappointed when someone beats it that quick and go back and try it again. So there's a few features I want to talk about in leaderboards. The first, we give you the ability to include both a built-in and custom UIs.
We have filters so that you can filter by both time and audience. We have combined leaderboards. This means that you can have, as we do in Roche and Beaux, three different leaderboards, let's say your rock, your paper, and scissors, and have a combined one so that you can show what the best times for all of them, which really gives you insight into maybe you need to rebalance your game.
If all the top scores are rock, maybe I'm doing something different with rock, and maybe that's just the bigger button or easier to press, and I can rebalance based off that. And other people can make decisions on what they want to do based off that information. We offer 25 leaderboards within your game.
We have a new feature that we're including in iOS 5, and it's the per score context. This is really great. We're going to go over this a little bit more later. But this allows you to include information about each score you submit. And so as you see here with Roshan and Bo, we're including which action they did when they made their win. So you see like Ghandi Zero has won with scissors. That's fantastic information to include.
So there are four development topics I want to talk to you about leaderboards. The first is how to define it. This is going to go over everything we need to do to include it within iTunes Connect. The second thing we're going to talk about is reporting a score.
Third topic is how to present leaderboards to your users. We're going to show you how to do this with the standard UI, and then later on we'll talk about customizing it in that section. And the fourth topic I want to talk to you about is recommended practices. So as you see here, this is exactly what we have for Roshambo.
The first thing we have on this list is the name. This is just an easy way so that you can identify each of the up to 25 leaderboards you have. And so we have Fastest Choice Rock. So we're going to talk about this leaderboard. And so Category ID is typically like a DNS type name, like we have com.apple.roshenbo, Fastest Rock. And this is probably the most important piece of information you need to keep because you're going to use this same Category ID for submitting your scores and displaying your leaderboards.
We offer a couple of different types. This one we're using an integer, but we also have opportunities to use money, time, integer. There's a whole bunch of them, so you can go take a look at them. Sorter, we have this to be low to high. That allows us to see that the faster the time, the lower the score, it's going to be at the top of the list. But this can also be high to low, and we'll talk about that in just a sec.
The rest of this board is things that you get to localize. And so I'm just going to go over the English stuff, but you can go in there and localize it for your different languages. So we have the name, what the score format is, suffix, which we're doing in milliseconds.
We also have the plural, and score range. Score range is really important for defining a maximum and a minimum. So this is optional, and we'll go over this a little bit more when we define it. And we'll go over this a little bit more when we submit our scores.
A few tips about defining your leaderboard. Score order is really important and it can sound a little obscure just by looking at it. High to low means top scores at the top, so that would be like most kills, most money, stuff like that. And low to high is what we have within Rochambeau with the lower time. This is really important because once you've published your app to the app store, you don't have an opportunity to change this.
Once it's set, that's it. So you're going to want to make sure that this is exactly as you expect when you test your app. The other thing I want to talk about is suffix. You'll notice that in the last slide we had milliseconds spelt out and we had a space in there. And so we could have just as easily used MS and not include that space. But really you have to define whether or not you want that so that we can present it properly within our view controllers.
Now let's go on how to report a score. This is really simple. All you need to do is create a GK score object, initialize it with what you need, like the category, set the score, and there's a few other options that we'll go over in a sec, such as context and setting the default. And then we're going to want to check for errors.
Let's go over this new context variable. This is going to be really great for including within your scores. And we have a lot of different options to be able to customize what this looks like. So you'll see here that we have a list of leaderboards that we're including within Rochambeau. We have the, we include scissors as what their last win was. Well, we can go even further than this and create some really great customization opportunities.
We can go and include stuff like your hand statistics. You could have, let's say you have a different game, poker, you include what your poker hand was when you won, or what everyone else had. You can include a lot of information. And because this is a 64-bit integer, there's a lot of different opportunities to include stuff. So, for instance, we use a bit field to define all the information that we want to include with a Russian boat.
But you can get really creative here, and don't limit yourself to just what's in that integer. You can include an index to your own server so that you can do some really creative stuff, like having ghost laps, whatever, replays, taunts, other ways to really get your players engaged and see who your best players are and how they came to this accomplishment.
Another new feature that we're including in iOS 5 is the ability to the default leaderboard. This is really an opportunity for you to help us create a better experience within Game Center. And that's because it really helps us to define what each player's top leaderboard is out of your list.
So, for instance, myself, I'm a big fan of Rock. You know how the saying goes, "Good ol' Rock, nothing beats that." Well, you'd expect that on my page in Game Center, you'd expect Rock to be the top leaderboard. And so now we have an opportunity to set that.
Now let's go over how to report a score. First, we're going to want to initialize a GK score object with the identifier, or the category, sorry. This is the same thing I mentioned before within iTunes Connect. Then we'll set the score value. This is also an integer, so you're going to want to make sure that you get it correct, especially if you're dealing with one of the more obscure instances like time and/or money or one of the other ones. Here's the context variable. As I mentioned, we're using a bit field, so we're using statistics to set the context. Then we're going to want to report the score to the Game Center servers. And lastly, we'll check for errors.
So the thing I want to mention about reporting scores and checking the errors is that if you've done everything correct, there really is only one area that you'll get. And that is a communication error. But if you have, for instance, not done the authentication properly or set up your game within iTunes, you might get one of these two errors. But in most cases, you will get communication errors. And within iOS 4, we expected you to save these for a later time and resubmit them once you have a connection again. But new within iOS 5, we will resubmit these for you automatically.
Another thing that you should consider when you are reporting a score is what steps you can take to limit cheating. One of the things that you're going to have is that with these great leaderboards, people are really going to try a lot of different things to get to the top. Most people will try to just play a game over and over and over again, which is great. But there's a few people who would rather find other means. So what you can do is go over a couple of different best practices.
And so this could be any time that you save any game state information, you're going to want to do so using a checksum or a hash. If you're doing stuff like iOS 4, saving your score to the side before you resubmit them, make sure those are hashed out correctly because those will just be binary files that are easily editable and they could change the score.
And as I mentioned before, We also offer an opportunity to limit your scores. And so let's say with time, well, you can't have negative time or you can't have certain ranges. So we set the limit from 0 to 10 seconds because once you're out over that, you're off your scoreboard.
Next topic I want to talk about is displaying your leaderboard. The first thing you notice here with the leaderboard that we're including within our game is that we have the ability to rate your games within your game. And this is included within every View Controller that Game Center has to offer. So no longer do you have to leave the instance of your game or put up a dialog box.
Every time you display our View Controllers, you'll get an opportunity-- your players will get an opportunity to rate your game. So to display one of our standard leaderboard View Controllers within your game, you're first going to want to create a GKE Leaderboard View Controller object. Then you'll set properties such as your categories, the time scope, and also your delegate for dismissal.
And then you're going to want to present it modally. Let's take a look at what some of the code will look like. You'll see here that we first create the GKE Leaderboard View Controller object. Then we're going to want to set those properties I talked about. You'll see here we're using the fastest rock that we've displayed earlier. We also are going to set the time scope and a few of the other variables.
Once we have set the delegate, we will then present it. In iOS 5, we have a new way to do this, and it's called Present View Controller Animated Completion. The completion area is new, and we hope that you guys can use that to whatever way you want to.
And lastly, we obviously have to define how the leaderboard will finish. And so here's Let's go over some best practices for displaying our view controllers. You'll notice here that I've screwed up. I did not do some of the best practices. The Russian bow is set to the wrong orientation.
And the reason for this could be... There's a couple of different reasons why you might run into this. But the most prominent one that we've seen is that people have used the old OpenGL template that came out with 2.0, I think. And this was an OpenGL instance that didn't use a view controller as the basis. And so we saw people trying to set the status bar to wherever they thought was the most appropriate.
And this ran into some really weird scenarios. You'd see this pop up like this, and that's wrong. And we'd see some audio bezels the wrong way. And just some really random ways. The best practice for displaying the view controller is to set the status bar to the right orientation. And that's what we've seen.
The best practice we could tell you right now is that you should use a view controller for presenting our UI. And so if you look at the new OpenGL template that's included with iOS 5, this will help you out and give you the right steps to the right directions.
So that's leaderboards. We went over how to define your leaderboards, submit scores, how you can use context in a really great ways to present new information to your user and really get them engaged in different ways that weren't possible before. We also went over how to set your default leaderboard. And this is a great way so that you can really help us present the best experience for your players. And we also went over how to display standard view controllers. Next, let's go on to achievements.
Achievements are really great. These are a great way that you get to reward your players for doing something fantastic within your game. For instance, we have a couple different ones within Rochambeau, like win three times in a row with rock. This might sound easy, but who in their right mind is going to let you win with rock three times in a row? It's actually quite challenging.
But there could be other things like finding secret passageway, finding a new weapon, doing something on one of the edge cases of whatever your game is, defeating 50 enemies. This is a great way to really engage your players, get them to explore all that your game has to offer. And it really encourages competition amongst your players friends.
Some of the features that I want to talk about with achievements are we support up to 100 different achievements per title. We have different UIs, including Customize UI, and we also have Standard UIs to show. We have progress support, and so we allow you to show how far they've come on this achievement within our view controllers.
We also have the ability to hide achievements. This is a really great way so that you can get your players guessing of what the next thing is going to be. And this is really fantastic. When a player looks at their friend's achievement list and they have something that they didn't even know about, it's like a little surprise. And they can really get encouraged to really try out your game in multiple different ways.
We're including a new feature within iOS 5, the Completion Banner. This is a really easy way so that you can get your players engaged whenever they accomplish an achievement. And we also offer Achievement Points. This is kind of like the currency of achievements. Achievements or Achievement Points are really a great way so that you can differentiate the difficulty of all your achievements.
They can be anywhere from 0 to 100 points. And you might think, well, why would I want an achievement of 0 points? That seems kind of counterintuitive. Well, I've actually seen some really interesting ways to use this, including, let's say, having an achievement for something negative and giving 0 points for it, like losing five times in a row.
Well, I don't want to lose five times in a row. So you give 0 points. And it's a great way to kind of have negative achievements. But in most cases, you're really going to want to give more achievement points for the difficulty or the challenge of doing those things within your game.
Each title is allowed up to 1,000 points. You're going to want to make sure that you leave room for improvement within your game. That means if you include in-app purchase or you include some other features, you're going to want to budget accordingly and leave some room so that you can add new things.
It keeps people wanting to come back after they've accomplished all in the first version. Another new thing that we're including within iOS 5 is the Achievement Leaderboard. We think this is going to be a great drive for people to really do well within their achievements. And it's going to create a new competition to get these points.
So there are five topics I want to go over today with achievements. The first is how to define them within iTunes Connect. We'll go over an example within Roche and Beaux and show you how to do that. The second topic I want to go over is how to report your achievements to the Game Center servers. The third is how to present completion banners. Like I said, these are a new feature that we're including within iOS 5, and these are really easy, so I'll go over those.
The fourth topic I want to go over is key value data. We heard in the keynote that this is a new feature included with the new iCloud servers. So we'll go over everything you need to do to include this. And the last topic we'll go over is how to present achievements to your users.
So as you see here, we have an instance of winning three rocks in a row on Rochambeau. We have the name, similar to your leaderboard name. It's just something so you can define it. We have the ID. This is how we're going to want to submit them within your game. So hold on to that. It's also a DNS name, or it's recommended at least. We have the ability to hide it. This one's going to be obvious, and we're setting it to no.
We set the point value and we think this is a really tough challenge to do yet, so we're going to use the maximum of 100 to do that. Then we have some localization and stuff. And lastly, I want to mention the image. And the image is a little different.
I'll go over what you need to do for this now. We offer a couple of different image supported types for both achievements and the leaderboard image. And although we do, we really highly recommend using the PNG. And the reason for that is PNG supports the alpha channel. And this is really great because we do a bit of post-processing on every achievement image when we include it. And we can incorporate it within our view controllers. For instance, for achievements, we add this really nice gold coin behind your image. Then we apply a mask.
And then we add a gold coin to finish it off. And so by including an alpha, it really goes together really nicely. Now let's go over how to include completion banners within your game. This is a really great feature because if you're really going to get players interested in your achievements, you're going to want to present to them every time they accomplish it. And so we've seen a lot of really great ways to do this, but we wanted to include our own that's just really easy to use.
And you'll see just there, all it takes is one line of code. Every time you submit your achievement, set it to yes. When you've completed that achievement, a little banner will pop down really easily. But we didn't stop just there. We also include a way to include custom banner to be shown.
And so, for instance, I have here a hint. So you get to a point and you're almost about to get the achievement, but you've got discouraged or you decide to do something else. Maybe you give them a hint. Hey, you're almost there. Try a little bit harder. But not just that. There's other ways you can use it as well. It's a great way to get a message across to your user. Let's go over how to report these achievements.
First thing we're going to want to do is create a GKE Achievement object, initialize it with that achievement ID that we talked about earlier, set the percentage complete that you want done, then report it to the Game Center servers, and then check for errors. Let's take a look at what this looks like in code.
You'll notice here that we're using the 1-3 rocks, and so we're creating a GK achievement object there. We set the percentage to 80. We set the achievement, sorry, the shows completion banner to yes, but you'll notice since we're only setting the percentage to 80, it won't be shown quite yet. Then we report the achievement to the Game Center servers, and then we're going to want to check for errors.
As we did with GKScore and submitting scores, in most cases of the error, you're only really going to want to worry about the communication error. And in iOS 4, this was an issue that we wanted you to hold onto these and submit them later at a time later on. But new in iOS 5, we'll do this for you, which is really fantastic.
The fourth topic I want to talk to you today is about key value data. This is a new feature included that allows us to use the iCloud services within our game. This is really easy to use and it has a lot of great benefits to you as a game developer. For instance, one of the big things that we're using within Rochambeau is the ability to have it on both your iPhone and your iPad.
And the big piece of game data that we're syncing between them is our achievements data. Our achievements can be sometimes a little bit more complex and just being able to use how much the percentage complete is done isn't enough. So whenever we have any kind of complex game data, we can now use the iCloud support to sync these across multiple devices. This is really easy to use because it's similar to NS user defaults.
And all you need to do to include it within your game is to include a special entitlement. Now let's take a look at what some of this code looks like. All you need to do to set an object within the iCloud is to first grab the NS ubiquitous key value store, the default store object, set the object, and then synchronize. It's that easy.
The one thing I will mention that's not up here on the slide is that you're going to want to make sure that you use a key that associates with your player ID. And the reason for that is that your Game Center ID and your Cloud ID might be different.
Let's say you have multiple players using a similar device. So you don't want them to clobber each other. And now here's the code to get it from our servers. And it's the exact same way. You just do it in reverse. And so you grab the default store, synchronize, and then you grab the object.
The fifth topic I want to talk to you about on achievements is displaying them to your user. Your user really will want to know how far they've gone in all these achievements that you're including. And so by presenting them to them using the GKE Achievement View Controller, they will really get a sense of how they're doing within your game. So first to do this, we will create an object, set the delegate for dismissal, and then present it. It's really that simple. Let's take a look at what this code looks like.
So first, like I said, we create the GKE Achievement View Controller object. We set the delegate to whatever view controller you're coming from. We'll present it using the new method within iOS 5. And then we'll make sure that we've defined the achievementDidPressDismiss to whatever the rate of value is.
So that's what I want to talk to you on achievements. And so we went over a lot of things, including that these are a really great way for you to really reward your players. And they really create competition between your friends and increase engagement so that they can come back wanting more.
We also showed you how to include completion banners. This is a great way so that you can get your players really engaged with every time that they've accomplished a new achievement. And lastly, we went over the ubiquitous key value data store. And this is a really great way that you can really extend your game. So with that, I want to bring up Jordan Ceccarelli to show us all about Rochambeau. Thank you, Jordan.
Hello, good morning everyone. I'm Jordan Ceccarelli and I'm going to show you some cool stuff with the demo app that he's been talking about. It's called Rochambeau. And I'm going to show you how we've used Game Center to make it really cool. So let's see here. So here's the game, Rochambeau.
As you can see here right on our launch screen, in addition to being able to play the game, we give the user access to the leaderboards and the achievements right here from the main menu. As a gamer, I love that. I love being able to just immediately go right into this stuff without having to go into Game Center. So that's really cool.
We're going to play the game, and we've got three game types here. A single player versus the CPU. This is a four-player game, so you and three computer opponents. We also have a live player peer-to-peer game, and we also have a turn-based game. And we'll talk about those two in a later session today. So today we're just going to focus on the single player game.
So what's going to happen here, we're going to get presented with our three choices, rock, paper, and scissors. And so we're going to pick our instrument of choice here and go against the computer. So let's say rock. Nothing beats rock, right? So we'll pick rock. And as you can see here on the bottom, we have the computer opponents, Hard Rockin', Paperboy, and Stabby Stabby. And on the bottom, we get to see what they've picked, and we get to see the time that they've taken to pick their choice. And it looks like I totally lost a paper. So that happens sometimes. So I don't want to play again.
But maybe I do. So we're going to show you one cool thing. It's the banners that slide in, and you're allowed to put in notifications and messages, or we can have those pop up for achievements. So one of the notifications we have in here is if you try to select one of these options before the three, two, one countdown, we penalize you 500 milliseconds. And we give you a little banner notification to tell you that.
So we'll play the game again. And rock, rock, rock, come on. Rock, rock, rock, rock, rock, rock, rock. Slow down. Now as a player, I like that. I like that instant feedback. So that's really fun. We'll pick rock again, and let's see how we fare this time. Looks like I'm coming in dead last.
Okay, well, when I practiced this, I was winning, I promise. So, next up, let's talk about some of the other things here. We've got our in-game leaderboard sheet. And we've got the leaderboard between, let's see, these are our top friends. I'm in dead last of my friends. And then under here, you get to see the world players that have played this game and where you rank on this leaderboard. We can go back and see, in this case, the five leaderboards that we have here.
And one thing you'll notice, this does look different than we shipped today. And you'll notice that we have this nice red felt up top with game name and the icon. And you also see these five kind of transparent icons. And as Alex mentioned, this is actually a store rating.
And this is great because I'm sure you've all played a game before. And you've been playing it. You're kind of getting into it five or 10 minutes in. And all of a sudden, you get the alert. And it's like, rate my game. And you're like, oh, I'm in the groove. I'm playing. I don't want to go to the store now. I'd love to rate your game, but I don't want to leave.
So this is a great place because when someone is checking out leaderboards or achievements, that's a good time to say, hey, you like this game? You can rate it. So if I'm coming in here and I want to check out a score, I can go, great. I love this game. I'm giving it five. stars. So this is probably a pretty big win.
And here we have our achievements. And I like achievements. Every gamer likes achievements. So we can instantly see the achievements that we've unlocked while we've been playing this game. And once again, we have the star ratings right here. This is a great place for people to rate your game. So as you can see, we have our green felt for the leaderboards and achievements. And maybe -- you know, it looks pretty cool, but maybe this doesn't really go with your game theme. Maybe the green kind of clashes for you.
So with iOS 5, we're going to give you the ability to put custom UI in the game. So here we go. For leaderboards, this is now our custom UI leaderboards. Beautiful. This looks nicer than the green felt because it actually fits in the theme of the game with the blue ribbon. So just like our regular leaderboards, here's our leaderboards for this game. And you can see here that we have some of the new photos, some players that have selected photos, and we have some players that haven't selected photos. So they'll pop up as a silhouette there.
And we give you the opportunity to put pretty much whatever you want here. So in this case, we have, you know, the instrument they chose for their last win. So a lot of good information here. We have the time selector up top, just as you'd expect for a regular leaderboard.
Now let's look at achievements. Here is what we're calling the trophy room. This gives you the exact same set of achievement data showing you the ones you've unlocked and ones that are still hidden. But instead of being on the green felt, you have this nice little trophy room. So if you want to sit back and look at all the achievements you've unlocked, this looks beautiful.
So I happen to like this custom UI. I think it fits well with this game. But you know what? I think you guys can do better. I have a lot of faith in you guys. I'm looking forward to playing your games. I want to see some custom UI. I want to see some achievements. I want to see some banner notifications. I know you guys can do it. So with that, thank you very much. Back to Alex.
Thanks a lot, Jordan. That was fantastic. So with that, let's go on to our final topic of the day, and that is customization. So as we saw within Rochambeau, We offer you, we've showed you both how to use the original one, the GKE Leaderboard View Controller and the GKE Achievement View Controller.
And then we also went into customization. But why would you want to customize? The standard one, as we've gone over today, is really nice and offers really great features. And it's extremely easy to use. It's three lines of code, like five lines of code if you add some of the other stuff in there.
But in a lot of cases, you do want to customize because you really want to fit the best experience for your game. And as we did with Rochambeau, we thought that the green felt just didn't match the kind of art direction that we were trying to go with. So we went out and we created a great trophy room.
And we also created a great leaderboard that used some of the new features that we're including within iOS 5. The context variable really offers some great opportunities to get more information into your leaderboard and show new ways to really make it kind of give that extra little pop.
So as we see here, we have the ability to show who won and with which instrument. But don't let this be the only thing you want to use. You can go even further than that, like including replays and new opportunities to include other data that might be really useful.
The thing with Rochambeau is when I'm playing against my friends, I actually do want to know a little bit of information about what kind of things that they've done in the past. Like are they a big fan of ROK? Like I'm a big fan of ROK. So everyone's going to want to use paper against me. Well, maybe that's something I want to keep consider, reconsider when I play them.
Okay, so there's two topics I want to go over within customization. The first, is going into how to get that information, how to get the leaderboard and achievement data so that you can create a great experience for your users. The second is how to use player photos within your game. So we offer three different classes that give you access to the data that our Game Center servers have to offer. And so those are the GKE Leaderboard, GKE Achievement Description, and the GKE Achievement.
So this gives you all the information you need. So be creative. Like, if you're going to spend the effort to create an all-inclusive experience, make sure that it's purposeful. Like, have something that really makes the user go, yes, this is exactly what I want to know. So first, let's talk about what custom leaderboards can offer you.
The leaderboard data that we include can be queried programmatically. And so you don't actually just need to create custom leaderboards. You can actually use some of this information for other reasons. Like, let's say I'm about to create a multiplayer game. I might want to see where all my players that I'm playing against rank against me so that I can make my decisions. Maybe Jordan is the best player out of all of us. I want to ally with him. If we're playing an allied game, I definitely want to be on his team.
So a typical query could be anything like, let's say, top 10 players. A couple of different ranks. You might want to get a list of certain players, scores, stuff like that. And your queries are returned to you asynchronously, as are most of the Game Center APIs. And so, We set a limit at 100 so that you don't query the whole database. But we also want you to kind of be a good network citizen and make sure that you do low frequencies. Don't try to circumvent the system by making multiple calls to load the whole database. In most cases, you only need to show a minimal amount of information.
So what you'll need to do to load this leaderboard information is create a GKE Leaderboard object. Set the properties that you are requesting and then submit it asynchronously. Let's take a look at what this code looks like. First, we're going to want to create the GKE leaderboard object. Then, we'll set the category for which leaderboard we want. We also offer some method calls so that you can get a list of all the categories possible. But in this instance, we're going to only talk about the fastest rock that we've been talking about all night.
For instance, in this instance, we're going to want to look for all our players' top scores within the last week. And we're going to only look for the top 25. You'll notice here that our range is from 1 to 25, and that's because our leaderboards are done with a starting at 1. So make sure that you don't submit looking for 0 because there is no 0th player.
And so finally, we're going to want to submit this. And so we submit using load scores with Completion Handler. And this will return back an array of scores. So once we've done that-- We'll check for errors and send a completion block. This completion block, as similar with all of our asynchronous blocks, we're going to want to make sure that we only check to see if scores are submitted or sent back to us in the scores variable.
If we don't get something from them, then we can check for errors. The fact of the matter is even if we are having a communication error, if we have this information within Game Center stored from a previous instance, we will send these back to you. So just check to make sure that we've included the scores.
Next, let's talk about how to get the information for GKE achievements. So we can query this in two parts. First, we have the GKE Achievement. An instance of all the GKE achievements that you've submitted by the time you make this call. So if you have not made any progress on your achievements, you won't get anything back. So that means that we're going to use the GKE achievement description to get a list of all the achievements possible. So let's take a look at what this will look like in code.
It's actually really similar, the two of them. So to query the achievements data, we're going to want to first, use the nothing called load achievements with completion handler. This will return back an array of all the achievements that you've already submitted at this point. And then, similarly enough, you just want to check to make sure those achievements have been done. And if there is an error, send a UI feedback.
Similarly with GKE Achievement Description, we're going to want to load Achievement Description with Completion Handler. Then make sure that the descriptions are there. So the second topic I want to talk to you today on customization is how to include player photos. This is a new feature that we're including within iOS 5. So you can now grab the exact player photo that's included within Game Center within your game.
And it's really easy to use. All you need to do is load whatever player you're looking for, request a photo, and check for errors. So you'll see here within Rochambeau, we offered photos as a way to really get some more player involvement with when a player has won or not. So for instance, right now I've won, so I got to do a paint splat on the opponent that I faced, which gives me a lot of gratification. Because it's a way that I can really feel like, hey, I just beat this guy, splat, you're dead.
Player folders are a really great way that you can include. So let's go over them. To do this, reload a player, we're going to request a photo, and then check for errors. If we don't get anything back, we're going to want to include a default image. And this can be anything that really fits the theme of your game.
So this is what this looks like in code. First, we're going to want to call-- we'll do it, for instance, on the local player. We'll load a photo with size, and we offer a couple of different sizes, and then we'll pass in a completion block. This completion block will then hand you a photo and an impossible error. And then all you need to do is set whatever your image is to the photo that we give you back. And if you do get an error, use whatever your default image is. And this should really fit whatever the theme is of your game.
So that's your customization section. So the things that I went over today are I gave you all the tools necessary so that you can create really great leaderboards and achievements within your game that really fit the look and feel that you're looking for. And this is a really great way so that you can really stand out, really have your game be a complete experience.
And new with our player photos in iOS 5, you have a new way to increase player engagement. So when you're playing multiple people, as we'll show you in our next session, you have a way to really bring the experience alive by having your player photo part of the experience.
So that's it for this session. I want to go over a few things that I talked about today. The first thing we went over was how to set up. And I'm not going to talk too much about that in review because I think you guys got the point. Second is leaderboards. We went over everything you need to do to include a leaderboard within your game.
We also went over how to include context in your game. And this is a great way for you to offer some really great customization tools. We also went over how your players can now rate your games from within the game. And they're included in all the view controllers that Game Kit has to offer. We went over achievements.
Everything you need to do to include achievements as a way to reward your player for tasks that they have done. And we also went over how to show these to your users when they've completed them using the new completion banners. And lastly, we went over customization. These are the tools that you're going to need so that you can really include a great experience to really bring the whole thing together to your look and feel. And we did this by using photos and showing you how to use them.
And we also went over how to grab the data from the leaderboard and achievements. So the related sessions that we have, we have two of them today, and then we have a repeat of the introduction on Friday. So the two are multiplayer, which happens right after this one in this room.
And then we have turn-based gaming. This is a great new feature that we're including in iOS 5, and that will happen at 11:30 today in this room. If you want more information, please contact Alan Schaffer and the great evangelism team that we have here at Apple. And with that, thank you very much. I can't wait to see what you guys have to offer.