thanks for the sample. This is how I do it too. Sure, with my test code I have only one player and friend so far. Myself (WhiteskyGames)! So I expected to have my player ID returned in the friends list. But I got nothing.
To load the players list, I did it like this:
gamekit:loadPlayers({"WhiteskyGames"})
As I said, I get only back an empty table. No error. When I debug in XCode, this call to loadPlayer like I have shown aybove, actually gets an error which is not nil in XCode, but in LUA I get no error.
loadPlayers function accepts player IDs (like "G:1085204981") not aliases (like "WhiteskyGames"). You can pass the friends list retrieved from loadFriends to loadPlayers like:
require"gamekit"localfunction onAuthenticateComplete(event)if event.errorCode ~=nilthenprint("error while authentication: "..event.errorDescription)elseprint("authentication successful. now loading friends...")
gamekit:loadFriends()endendlocalfunction onLoadFriendsComplete(event)if event.errorCode ~=nilthenprint("error while loading friends: "..event.errorDescription)elseprint("here are the friends:")for i=1, #event.friends doprint(event.friends[i])end
gamekit:loadPlayers(event.friends)endendlocalfunction onLoadPlayersComplete(event)if event.errorCode ~=nilthenprint("error while loading players: "..event.errorDescription)elseprint("here are the details of friends:")for i=1, #event.players doprint(event.players[i].playerID, event.players[i].alias, event.players[i].isFriend)endendend
gamekit:addEventListener("authenticateComplete", onAuthenticateComplete)
gamekit:addEventListener("loadFriendsComplete", onLoadFriendsComplete)
gamekit:addEventListener("loadPlayersComplete", onLoadPlayersComplete)
gamekit:authenticate()
I've just tried to give invalid player ID like "WhiteskyGames" and this error occurred: The requested operation could not be completed because the player is invalid.
Thanks for the info Atilim. I was trying to find information about this but somehow I must have not understand this.
The friends list won't include the local player, even if it is shown there like in the image I have posted on top? Because it is listed there, I was expecting it to be in the list.
And is that by apple design, that you need to build a table like the friends list as an input param for loadPlayers, or your implementation?
Yes, I have only one friend and I get that one. btw, running gamecenter in a sandboxed environment can be different. Can you add a friend to your sandboxed gamecenter account and try again? (I have two gamecenter accounts: one for real and one for sandbox)
Dear, I have some question about game center. At the moment, I've already - implemented code as above, - config ituneconnect (see attachment)
but when running in iPad player, it says "This game is not recognized by Game Center".
My questions are: - Could gamecenter work with iPad player? - I have no experience with Leaderboard & Gamecenter, would you please give me a hint! - How can I post score to leader board?
To get gamecenter working you need to create an app in itunes and enable gamecenter for it. Then you need to create the gideros player with the same Id like your app. I will post code for interfacing with game center later.
It's ok now for me. I'm able to view leader board but: - I have 3 leader board, and only default leader board which selected in ituneconnect is displayed first. I wanna open a specific leader board, how can I ? - How can I submit score to leader board.
How easy would it be to modify the game center code to return stub demo code? I've always wanted to add game center but I take months to develop anything (this isn't my full time job) and I know Apple has a time limit on how long they allow the apps created in iTunes without binaries (to prevent name squating). So I've always kinda dreaded doing this because then I'd have a deadline and this really is just a side thing and app deadlines isn't something I'm good at.
I took a look at gamekit.mm today and saw that there's no automatic way to get such infos. Here's quick my solution:
- Add a new function: getScores(category) to gamekit.mm which returns a GKScore array In GKScore we have some useful info such as: playerID, value, rank - Then in game code implement these steps: + Get the set of scores + Then we can have a set of player IDs + Pass that set to loadPlayers (which is already in gamekit.mm) + Then we can have a set of player infos (alias,...) With that, we can have a table of (playername, score, rank)
Hope my description is clear. What do you think?
I needed this to implement an interesting feature to my game Evolush. This feature was suggested by a member on this forum So far I've already been able to retreive such infos, will integrate to my game tomorrow
Hi, I was reading this discussion about Game Center, but can't figure out how to show the leaderboard within my app. There is any kind of example with the complete set of functions concerning gamekit ?
@paulcarrasco, I was stuck several hours figuring out how to display anything related to GameCenter. Since I am usually using internal GiderosPlayer, I got LUA error messages when I added
require "gamekit"
In the meantime, my understanding is, that it's not included in the GiderosPlayer, but it's added to the GiderosIOSPlayer oder GiderosAndroidPlayer. So after running the Player on the device with the above line and adding
gamekit:authenticate()
the GameCenter authentication screen shows up! Maybe everybody knows that and I just missed the section explaining that, but it might also be possible it's the same problem you're having.
Hi, I was reading this discussion about Game Center, but can't figure out how to show the leaderboard within my app. There is any kind of example with the complete set of functions concerning gamekit ?
Comments
Nice!
Via plugins?
Likes: neo89
www.tntengine.com
What is the correct syntax to do it?
thanks for the sample. This is how I do it too. Sure, with my test code I have only one player and friend so far. Myself (WhiteskyGames)!
So I expected to have my player ID returned in the friends list. But I got nothing.
To load the players list, I did it like this:
Cheers
Michael
loadPlayers function accepts player IDs (like "G:1085204981") not aliases (like "WhiteskyGames"). You can pass the friends list retrieved from loadFriends to loadPlayers like:
The requested operation could not be completed because the player is invalid.
The friends list won't include the local player, even if it is shown there like in the image I have posted on top? Because it is listed there, I was expecting it to be in the list.
And is that by apple design, that you need to build a table like the friends list as an input param for loadPlayers, or your implementation?
The API is very similar to Apple's design. Even the function names and the parameters they take.
I am sorry, but I don't get any entry in the friends list. Do you?
Cheers
Michael
I have some question about game center. At the moment, I've already
- implemented code as above,
- config ituneconnect (see attachment)
but when running in iPad player, it says "This game is not recognized by Game Center".
My questions are:
- Could gamecenter work with iPad player?
- I have no experience with Leaderboard & Gamecenter, would you please give me a hint!
- How can I post score to leader board?
Regards,
Likes: phongtt
It's ok now for me. I'm able to view leader board but:
- I have 3 leader board, and only default leader board which selected in ituneconnect is displayed first. I wanna open a specific leader board, how can I ?
- How can I submit score to leader board.
Thanks,
My apps: http://www.yummyyellow.com
I would like to get the following information:
- Who is the best player of my game & how much score he have got
- Current user's ranking
would you please give me a hint!
Regards,
Here's quick my solution:
- Add a new function: getScores(category) to gamekit.mm which returns a GKScore array
In GKScore we have some useful info such as: playerID, value, rank
- Then in game code implement these steps:
+ Get the set of scores
+ Then we can have a set of player IDs
+ Pass that set to loadPlayers (which is already in gamekit.mm)
+ Then we can have a set of player infos (alias,...)
With that, we can have a table of (playername, score, rank)
Hope my description is clear. What do you think?
I needed this to implement an interesting feature to my game Evolush.
This feature was suggested by a member on this forum
So far I've already been able to retreive such infos, will integrate to my game tomorrow
Thanks in advance to all.
require "gamekit"
In the meantime, my understanding is, that it's not included in the GiderosPlayer, but it's added to the GiderosIOSPlayer oder GiderosAndroidPlayer. So after running the Player on the device with the above line and adding
gamekit:authenticate()
the GameCenter authentication screen shows up! Maybe everybody knows that and I just missed the section explaining that, but it might also be possible it's the same problem you're having.
Hope it helps. Regards
Michael
http://www.giderosmobile.com/forum/discussion/1932/game-center-example-code-for-leaderboards#Item_8