Quick Links: Download Gideros Studio | Gideros Documentation | Gideros Development Center | Gideros community chat
Game Center just works great! - Gideros Forum

Game Center just works great!

MikeHartMikeHart Guru
edited January 2012 in Relax cafe
Hi folks,

I just have implemented Game Center in my game:

http://twitpic.com/8749gp

Likes: atilim, bowerandy

Tagged:
+1 -1 (+2 / -0 ) Share on Facebook
«1

Comments

  • DRSDRS Member
    Mike,
    Nice!
    Via plugins?
  • Yip, via the sample plugin that ships with beta 7.

    Likes: neo89

    +1 -1 (+1 / -0 ) Share on Facebook
  • DRSDRS Member
    Thanks for the info
  • wow Mike!
    TNT ENGiNE for Gideors Studio - Particle Engine, Virtual Pad, Animator Studio, Collision Engine - DOWNLOAD NOW !!! IT'S FREE!!! -
    www.tntengine.com
  • Ok, I need help now. I can submit scores and show the leaderboard. When I want to retrieve the friends list or players list, I get empty tables.

    What is the correct syntax to do it?
  • atilimatilim Maintainer
    edited January 2012
    Hi Mike, here is an example code:
    require "gamekit"
     
    local function onAuthenticateComplete(event)
       if event.errorCode ~= nil then
          print("error while authentication: "..event.errorDescription)
       else
          print("authentication successful. now loading friends...")
          gamekit:loadFriends()
       end
    end
     
    local function onLoadFriendsComplete(event)
       if event.errorCode ~= nil then
          print("error while loading friends: "..event.errorDescription)
       else
          print("here are the friends:")
          for i=1, #event.friends do
             print(event.friends[i])
          end
       end
    end
     
    gamekit:addEventListener("authenticateComplete", onAuthenticateComplete)
    gamekit:addEventListener("loadFriendsComplete", onLoadFriendsComplete)
    gamekit:authenticate()
  • atilimatilim Maintainer
    Maybe you're trying to retrieve friends before authenticating?
  • Hi Atilim,

    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.

    Cheers
    Michael
  • atilimatilim Maintainer
    edited January 2012
    Hi Mike,

    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"
     
    local function onAuthenticateComplete(event)
       if event.errorCode ~= nil then
          print("error while authentication: "..event.errorDescription)
       else
          print("authentication successful. now loading friends...")
          gamekit:loadFriends()
       end
    end
     
    local function onLoadFriendsComplete(event)
       if event.errorCode ~= nil then
          print("error while loading friends: "..event.errorDescription)
       else
          print("here are the friends:")
          for i=1, #event.friends do
             print(event.friends[i])
          end
          gamekit:loadPlayers(event.friends)
       end
    end
     
    local function onLoadPlayersComplete(event)
       if event.errorCode ~= nil then
          print("error while loading players: "..event.errorDescription)
       else
          print("here are the details of friends:")
          for i=1, #event.players do
             print(event.players[i].playerID, event.players[i].alias, event.players[i].isFriend)
          end
       end
    end
     
    gamekit:addEventListener("authenticateComplete", onAuthenticateComplete)
    gamekit:addEventListener("loadFriendsComplete", onLoadFriendsComplete)
    gamekit:addEventListener("loadPlayersComplete", onLoadPlayersComplete)
    gamekit:authenticate()
  • atilimatilim Maintainer
    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?
  • atilimatilim Maintainer
    edited January 2012
    You're right.

    The API is very similar to Apple's design. Even the function names and the parameters they take.
  • Hi Atilim,

    I am sorry, but I don't get any entry in the friends list. Do you?

    Cheers
    Michael
  • atilimatilim Maintainer
    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?

    Regards,
    gamecenter.png
    966 x 542 - 22K
  • 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.

    Likes: phongtt

    +1 -1 (+1 / -0 ) Share on Facebook
  • Hi MikeHart,

    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,
  • To submit a score to a leaderboard:
    gamekit:reportScore(yourgameScore, "leaderboardID")
    The gideros implementation only displays your default leaderboard. To set the category, you need to add this parameter to the plugin atm yourself.
  • 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.
  • RickyngkRickyngk Member
    edited March 2012
    Thanks MikeHart, it's work fine. I was got problem with sandbox, it's delayed too long. But ok right now.
  • I was got problem with sandbox, it's delayed too long. But ok right now.
    That is a normal behaviour with the GC Sandbox. Nothing wrong there.

  • Dear,

    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,
  • I am not sure if it is implemented in the plugin and if these info are retrievable at all. But I will have a look this week.
  • phongttphongtt Guru
    edited June 2012
    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 :D
  • 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 ?

    Thanks in advance to all.

  • @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.

    Hope it helps. Regards
    Michael
  • 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 ?

    Thanks in advance to all.

    This might help you out ;-)

    http://www.giderosmobile.com/forum/discussion/1932/game-center-example-code-for-leaderboards#Item_8
Sign In or Register to comment.