Gamecenter is successfully initiated, however the score will not post.
First, _G.score exists, i promise. Everything is set up in itunes connect, the only problem is posting the score. Thanks!
[lua]local gameNetwork = require “gameNetwork”
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
gameNetwork.init( “gamecenter”, initCallback )
if loggedIntoGC == true then
local function requestCallback( event )
I’m a little thrown off by your “ifs” and “ends” here.
It doesn’t look as though line 16 is within a function.
Is this throwing any errors when called?
Have you tried prints statements to debug? (Such as a print statement right before setting the highscore?) [import]uid: 52491 topic_id: 22334 reply_id: 89008[/import]
local function requestCallback( event )
if event.data then
native.showAlert( "Success!", "", { "OK" } )
end
end
if loggedIntoGC then
gameNetwork.request( "setHighScore",
{
localPlayerScore={ category="com.boltvisual.L.arts", value=\_G.score },
listener=requestCallback
})
end
Not fully sure if that will make a difference or not but thats how I have mine setup and it works. if thats not it, the only other thing I can think of is making sure your category spelling matches up with what you set in Connect. might of accidentally messed something up in one of them. [import]uid: 69700 topic_id: 22334 reply_id: 89018[/import]
so the logging in works, but the native alert for the event data does not…
[lua]local gameNetwork = require “gameNetwork”
local function all()
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
– function to listen for system events
if loggedIntoGC == false then
gameNetwork.init( “gamecenter”, initCallback )
end
local function requestCallback( event )
if event.data then
native.showAlert( “Success!”, “”, { “OK” } )
end
end
if loggedIntoGC then
gameNetwork.request( “setHighScore”,
{
localPlayerScore={ category=“com.boltvisual.L.arts”, value=_G.score },
listener=requestCallback
})
end
end
timer.performWithDelay(200, all, 1) [import]uid: 59735 topic_id: 22334 reply_id: 89081[/import]
okay, i got the native alert to print the score after it posts it from event.data. However, from the gameccenter app, i dont see the score increasing. Also, it only posts the first time? [import]uid: 59735 topic_id: 22334 reply_id: 89235[/import]
UPDATE: I figured out that at my menu scene, i was declaring loggedIntoGC false! All fixed. However, it still doesn’t update in the GC app…i am using a sandbox account. Is this normal? [import]uid: 59735 topic_id: 22334 reply_id: 89240[/import]
Just a question here… What is the point of wrapping all of that up into a function with a 2ms delay? Why not just leave it out of a function and it will trigger when that page is loaded into the app without any need for a timer and “all” function?
As far as the Sandbox/updating question, I’m not 100% on this one, but with my latest app which is the first time I’ve used GC, when I test on the iOS Simulator using the Sandbox account it doesn’t update any GC scores from my app when testing. But I released it using the same code that doesn’t update in the simulator and it all updates fine on the device to GC. [import]uid: 69700 topic_id: 22334 reply_id: 89247[/import]
A little late but yes, you can view print statements on device - just have it plugged into Xcode and view console [import]uid: 52491 topic_id: 22334 reply_id: 89256[/import]