Hi,
After reading blogs, API docs and forums threads, I thought I had it figured out.
I’m trying to get grips on GameCenter integration so I’ve made a test program that I want to use as basis for GC integration in my App in the next release.
So I created a Leaderboard for my app (currently in review for v1.0).
I connect to the GC, no problem.
I use the gameNetwork.show(…) to see that the Leaderboard does exist (it does
).
Now I try to set some scores to test reading and writing from/to the GC and that’s where things go wrong.
In the build.settings I’ve set the CFBundleIdentifier to my apps identifier.
After successfully connecting and showing the Leaderboard, I want to write some score to the board.
I use
gameNetwork.request( "setHighScore", { localPlayerScore={ category="Classic", value=10 }, listener=requestCallback } )
To write to the board (it exists). But nothing happens.
I’m not sure if it’s because the GC is currently in Sandbox mode (as it says in my test app when logging in). I’ve created a new GC account that I log into inside the test app.
- Is there a special way to create a test user to access the sandbox mode of GC?
- Am I doing something else wrong?
EDIT: an hour ago I suddenly had 3 (valid) score entries in my sandbox leaderboard. So I thought, let’s start with a clean slate now it’s working. So after a few minutes the leaderboard was cleared. Then however I submitted several scores but none shows (again)!
Is it normal that it takes hours for scores to be displayed on the GC? Or is this a “feature” of the sandboxed versions only?
Thanks all!!
This is the bare bones code:
---
local gameNetwork = require "gameNetwork"
local loggedIntoGC = false
display.setStatusBar( display.HiddenStatusBar )
local requestCallback
local function showBoard( )
if loggedIntoGC then
gameNetwork.show( "leaderboards", { leaderboard={ category="Classic" } } );
end
end
local function onSubmitScore( event )
if loggedIntoGC then
gameNetwork.request( "setHighScore", { localPlayerScore={ category="Classic", value=10 }, listener=requestCallback } ) ---leaderBoards[currentBoard]
timer.performWithDelay(5000, showBoard() )
else
native.showAlert("No network", "", {"OK"})
end
end
function requestCallback( event )
if event.type == "loadScores" then
-- do something with the data
end
end
local function initCallback( event )
if event.data then
native.showAlert("Succesfully logged in", "", {"OK"})
loggedIntoGC = true
gameNetwork.request( "loadScores", { leaderboard={ category="Classic", range={1,10} }, listener=requestCallback } )
showBoard()
timer.performWithDelay( 5000, onSubmitScore )
else
native.showAlert("Log in failed!", "", {"OK"})
end
end
local function onSystemEvent( event )
if "applicationStart" == event.type then
loggedIntoGC = false
gameNetwork.init( "gamecenter", initCallback )
return true
end
end
Runtime:addEventListener( "system", onSystemEvent )
[import]uid: 123200 topic_id: 23825 reply_id: 323825[/import]