Quick Links: Download Gideros Studio | Gideros Documentation | Gideros community chat | DONATE
Game Center just works great! - Page 2 — Gideros Forum

Game Center just works great!

2»

Comments

  • How can i get my score?
    local function onLoadScoreComplete(event)
       if event.errorCode ~= nil then
          print("error while loading players: "..event.errorDescription)
       else
    		print("here are the details of scores:")
    		print(event) -- how can i print?????????
       end
    end
     
    gamekit:addEventListener("loadScoresComplete", onLoadScoreComplete)
     
    gamekit:loadScores("grp.MyGroup")
    Where i find the gameKit api?

    tks
  • How can i get my ID of game center? I need this to get my score.
  • pedroluis5pedroluis5 Member
    edited May 2013
    already resolved everything

    to get my id i use this in onAuthenticateComplete event
    print(event.localPlayer.playerID)
    and to get score
    local function onLoadScoreComplete(event)
    	if event.errorCode ~= nil then
    	  print("error while loading players: "..event.errorDescription)
    	else
    		print("here are the details of scores:")
    		for i=1, #event.scores do
    			print(event.scores[i].playerID, event.scores[i].value,event.scores[i].category)
    		end
    	end
    end
  • just to help another users....here is a full example...
    GameCenter = gideros.class(Sprite)
     
    require "gamekit"
     
    local myScore=0
    local myID=0
    local leaderboardID
     
    local function onAuthenticateComplete(event)
       if event.errorCode ~= nil then
          print("error while authentication: "..event.errorDescription)
       else
          print("authentication successful. now loading friends...")
    	  print(event.localPlayer.playerID)
    	  myID = event.localPlayer.playerID
    	  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
     
    local function onLoadScoreComplete(event)
    	if event.errorCode ~= nil then
    	  print("error while loading players: "..event.errorDescription)
    	else
    		print("here are the details of scores:")
    		for i=1, #event.scores do
    			print(event.scores[i].playerID, event.scores[i].value)
    			if (event.scores[i].playerID == myID) then
    				myScore = event.scores[i].value
    			end
    		end
    	end
    end
     
    --////////////////////Extern functions///////////////////////--
    function GameCenter:Login()
    	gamekit:authenticate()
    end
     
    function GameCenter:ShowLeaderBoard()
    	gamekit:showLeaderboard(leaderboardID)
    end
     
    function GameCenter:PostScore(score)
    	gamekit:reportScore(score,leaderboardID)
    end
     
    function GameCenter:LoadScore()
    	gamekit:loadScores(leaderboardID)
    end
     
    function GameCenter:getMyScore()
    	return(myScore)
    end
     
    function GameCenter:setLeaderboardID(id)
    	leaderboardID = id
    end
     
    gamekit:addEventListener("authenticateComplete", onAuthenticateComplete)
    gamekit:addEventListener("loadFriendsComplete", onLoadFriendsComplete)
    gamekit:addEventListener("loadPlayersComplete", onLoadPlayersComplete)
    gamekit:addEventListener("loadScoresComplete", onLoadScoreComplete)
    :)
    +1 -1 (+6 / -0 )Share on Facebook
  • I have added a leaderboard using the gamekit to my game. But when I open the leader board it says 'no items' rather than displaying a leader board with scores.

    I have added the game via iTunes connect, and created a leader board.
    I call
    gamekit:authenticate()
    gamekit:reportScore(score,leaderboardID)
    gamekit:showLeaderboard(leaderboardID)

    The leaderboardID matches the id I gave it in iTunes connect.

    I have set the Bundle ID in Xcode to match the Bundle ID in iTunes connect.

    Enabled game centre in Xcode and in iTunes connect.

    Any idea what Im missing ?

    Thanks
  • Sometimes it shows me "no items" even for app that already has a hunreds of result. I'm not sure, but may be it is iOS bug. Try to close app and open leaderboard again.
  • ar2rsawseenar2rsawseen Maintainer
    edited March 2014
    It think it could show no items when it lost connection to server, or something like that (like no internet connection after authentication ? )
  • eezingeezing Member
    edited March 2014
    I spent a good portion of yesterday dealing with the same issue.

    My fix:

    As mentioned in the apple developer docs, login to Game Center using an iTunes test account instead of normal user account. You can create an iTunes test account in iTunes Connect. You can switch users by logging out of Game Center in settings app, then on the following Game Center initiation you'll get a login dialog.

    In the past with other SDK's, I've been able to test using my normal user iTunes account, but no dice here. Hope this resolves your issue.
  • Thank you, I will try and let you know how I get on.
  • Success.

    I added a test account, and now I can see a highscore table.

    thanks for the help.
  • Cool, glad that worked for you. :)
  • jdbcjdbc Member
    edited March 2014
    Has anyone tested the feature "invite to friend" or "challenge" in Game Center? It is not available in GameCenter plugin but it could be included in this plugin.
  • ar2rsawseenar2rsawseen Maintainer
    @jdbc as far as I was reading about challenges, they do not require any specific code and should be automatically supported in games with leaderboards, did I miss something? :)
Sign In or Register to comment.