// SHOWS GAME CENTER ACHIEVEMENTS / LEADERBOARD
// DISPLAYS INFO WHILE TRYING TO CONNECT
function ShowGameCenter( foo )
local connecting as integer
// create text to show the user that the app is trying to connect to Google Game Center
connecting = CreateText ( "Connecting to Google Game Center........TAP TO ABORT" ) : SetTextSize ( connecting, 4 ) : SetTextAlignment ( connecting, 1 ) : SetTextColor ( connecting, 92, 138, 199, 255 ) : SetTextPosition ( connecting, 50, 0 )
if GetGameCenterExists() = 1 // does device support Google Game Center?
if GetGameCenterLoggedIn() <> 1 then GameCenterLogin() // if still not logged in, try to login now. First login attempt should be made when app is launched
else
DeleteText ( connecting ) // device doesn't support Google Game Center, so delete info text and exit function
exitfunction
endif
repeat
sync()
until GetGameCenterLoggedIn() = 1 or GetPointerReleased() // wait until user is logged in or user taps screen
if GetGameCenterLoggedIn() // if user is logged in, show leaderboard or achievements, depending on the value that has been passed to this function
if foo = 1 then GameCenterShowLeaderBoard ( "<szBoardID>" ) // <szBoardID> = name of the leaderboard in your Google Play Console
if foo = 2 then GameCenterAchievementsShow()
endif
DeleteText ( connecting ) // at this point, user has closed leaderboard / achievements, so it's safe to delete the info text and jump back
endfunction
Help make AGK better by submitting an example for this command! (All examples are subject to approval)