I’m following the sample code to set up a Game Center leaderboard in my universal iOS game (Corona build 772), but the Leaderboard shows up empty – I see my icon and leaderboard title as I entered it in iTunes Connect for my app, but there’s no scores yet for Today/ Week/ AllTime (shows “No Scores”), even when I saved a score and also got the “Highscore Reported!” callback, and even waited several minutes. The game is not published yet, I’m still testing it (on the actual device, I’m using the iPad 3) using my developer profile.
When loading Game Center, the Apple message shows “Game Center ***Sandbox***”.
Q: Do scores not show up in the sandbox or am I doing something wrong?
A bunch of source code I’m using (not in order/ complete):
[code]
app.leaderboardId = ‘com.versuspad.mygamename.leaderboard’
– …
gameNetwork.init(‘gamecenter’, appCloudHighscoreCallback)
– …
function appSaveData()
if app.score > app.highestAllTimeScore or true then
app.highestAllTimeScore = app.score
if app.loggedIntoCloudHighscore then
appDebug(‘Saving…’)
local viewersInMillion = app.highestAllTimeScore * app.scoreToViewersFactor
gameNetwork.request( ‘setHighScore’, {
localPlayerScore = { category = app.leaderboardId, value = viewersInMillion },
listener = appCloudHighscoreSavedCallback
})
appDebug(‘Saved!’)
end
end
end
function appCloudHighscoreSavedCallback(event)
if event.type == ‘setHighScore’ then
local function alertCompletion()
gameNetwork.request( ‘loadScores’, { leaderboard = { category = app.leaderboardId, playerScope = ‘Global’, timeScope = ‘Week’, range = {1, 25} },
listener = appCloudHighscoreSavedCallback } )
end
native.showAlert( ‘High Score Reported!’, ‘’, { ‘OK’ }, alertCompletion ) – this point is reached
elseif event.type == ‘loadScores’ then
local userBest = misc.getIf(event.localPlayerScore ~= nil, event.localPlayerScore.formattedValue, ‘Not ranked’)
appDebug( 'userBest = ’ … tostring(userBest) )
end
end
function appCloudHighscoreShowLeaderboard()
if app.loggedIntoCloudHighscore then
gameNetwork.show( ‘leaderboards’, { leaderboard = { category = app.leaderboardId, timeScope = ‘Today’ } } )
else
appAlert(‘Please login to Game Center first’, true)
end
end
function appCloudHighscoreCallback(event)
app.loggedIntoCloudHighscore = event.data ~= nil and event.data – this one is true, works fine
end[/code]
Thanks! [import]uid: 10284 topic_id: 23910 reply_id: 323910[/import]