Hello people,
I implemented GameCenter for iOS on Corona. When I put game on real device you can see successful login on Game Center. Problem is when you open to see your score, there is show no ranking and sometimes game is crush. So, I want to share my code with you to see what’s going on.
mainmenu.lua (this is a script before starting playing a game)
local gameNetwork = require( "gameNetwork" ) local function loadPlayerRequestCallback(event) playername = event.data.alias playerID = event.data.playerID end local function gameCenterLoginCallback(event) gameNetwork.request( "loadLocalPlayer", { listener=loadPlayerRequestCallback } ) return true end gameNetwork.init("gamecenter", gameCenterLoginCallback)
restart.lua (this is a script when you lose on game, there you can see your score and highscore and there is a Game Center button)
local gameNetwork = require( "gameNetwork" ) function onClickGameCenter() gameNetwork.request("setHighScore", { localPlayerScore = { category="HERE IS MY ID NUMBER OF LEADERBOARD", value=100 --for example this value isn't read on leaderboard }}) gameNetwork.show( "leaderboards", { timeScope="AllTime" } ) end
That is all code which I used for Game Center. Am I missed something?
Thanks and kind regards
Dario