Hi people and community. I need help with GameCenter submitting score my problem is everytime I try to submit a score through a button click it won’t do anything here is what I mean
[code] module(…, package.seeall)
function new()
local localGroup = display.newGroup()
local scores = ice:loadBox( “scores” )
local high3 = scores:retrieve(“best3”)
print(high)
local score = 0
local time = 200
local ui = require(“ui”)
local bkg = display.newImage( “bkg.png” )
bkg.x = 160; bkg.y = 240
localGroup:insert(bkg)
local gameover = display.newText(“Game Over”,0 ,0 ,“Arial”, 30)
gameover.x = 160
gameover.y = 40
gameover:setTextColor( 0,0,0 )
localGroup:insert(gameover)
local highText = display.newText("", 0,0,“Arial”,22)
highText.x = display.contentWidth/2
highText.y = display.contentHeight/3
highText:setTextColor( 0,0,0 )
local highScore = scores:retrieve(“best3”)
if highScore ~= nil then
highText.text = "HighScore: "… scores:retrieve(“best3”)
end
local function show_highScore()
gameOver = not gameOver
scores:storeIfHigher( “best3”, score )
scores:save()
local highText = display.newText("", 0,0,“Arial”,22)
highText.x = display.contentWidth/2
highText.y = display.contentHeight/2
highText:setTextColor( 0,0,0 )
if score > high3 then
if score > scores:retrieve(“best3”) then
highText.text = "New HighScore: "… scores:retrieve(“best3”)
print(“new high score”)
else
highText.text = "New HighScore: "… scores:retrieve(“best3”)
end
end
end
timer.performWithDelay(time, show_highScore, 1)
local function onplay (event)
if loggedIntoGC then gameNetwork.request( “setHighScore”, { localPlayerScore={ category=leaderBoards[currentBoard], value=score }, listener=requestCallback } ); else offlineAlert(); end
if event.phase == “release” then
director:changeScene (“allaround”)
end
end
local function ongameselect (event)
if loggedIntoGC then gameNetwork.request( “setHighScore”, { localPlayerScore={ category=leaderBoards[currentBoard], value=score }, listener=requestCallback } ); else offlineAlert(); end
if event.phase == “release” then
director:changeScene (“play”)
end
end
playagain = ui.newButton{
default = “red1.png”,
over = “red2.png”,
x = 160,
y = 400,
text = “Play Again”,
onEvent = onplay,
}
gameselect = ui.newButton{
default = “red1.png”,
over = “red2.png”,
x = 160,
y = 330,
text = “Game Select”,
onEvent = ongameselect,
}
return localGroup
end [/code]
What I tried to do Is submit the score while changing scene. But I actually don’t know if I’m doing this right.
Help is appreciated thanks
[import]uid: 17058 topic_id: 20760 reply_id: 320760[/import]