hello again,
I tried to implement it. first I made
local gameNetwork = require “gameNetwork”
loggedIntoGC = false
local function initCallback( event )
if event.data then
loggedIntoGC = true
native.showAlert( “Success!”, “User has logged into Game Center”, { “OK” } )
else
loggedIntoGC = false
native.showAlert( “Fail”, “User is not logged into Game Center”, { “OK” } )
end
end
local function onSystemEvent( event )
if event.type == “applicationStart” then
gameNetwork.init( “gamecenter”, initCallback )
return true
end
end
Runtime:addEventListener( “system”, onSystemEvent )
to check my connection to game center and after i implemented your sample code in my project
local function postingScore( event )
– The shown Game Center popup was closed.
end
local function sendHighScore ()
gameNetwork.request( “setHighScore”,
{
localPlayerScore = { category=“bestofX”, value=score },
listener = postingScore
})
end
and i called this function at my endcondition as
if loggedIntoGC then sendHighScore() end
in my other lua file i implemented game center leaderboard button
-----local function onGameNetworkPopupDismissed( event )
– The shown Game Center popup was closed.
end
local function GoToLeaderboard( )
if loggedIntoGC then
gameNetwork.show( “bestoffragile”, { leaderboard = {timeScope=“AllTime”},
listener=onGameNetworkPopupDismissed } )
end
end
and call this method as onRelease of a button
why my game center implementation does not work?