gameNetwork.request("setHighScore") does not work on iOS. GameCenter bug?

Hi Wiler Jr,

Can you go back and indent your code so it’s easier to read? It’s hard to follow what is nested within what.

Thanks,

Brent

I suggest you put some prints in your code to check your math.  The first time you call the touch handler, the score that will be set is 25.  You’re saved value in composer was 0. 0 + 25 is 25 and that’s what got set.

Rob

I hope it’s better expressed… 

local widget = require("widget"); local gc = require("gameNetwork"); local composer = require( "composer" ) local leaderboardId = "winners"; local square, leaderboard, text; local function onSystemEvent( event )      if(event.type == "applicationStart") then         gc.init("gamecenter");         return true     end end Runtime:addEventListener( "system", onSystemEvent ) composer.setVariable( "currentScore", 0 ) local function showLeaderboards() gc.show("leaderboards", {leaderboard= {category="winners", timeScope="AllTime"}}); end local function setHighScoreListener( event )     print("setHighScore-----------------------------------------------------------")     print\_r(event) end local function handleButton( event )     text.text = composer.getVariable( "currentScore" ) + 25;     composer.setVariable( "currentScore", composer.getVariable( "currentScore" ) + 25 )     gc.request( "setHighScore",         {             localPlayerScore = { category="winners", value=composer.getVariable( "currentScore" ) },             listener = setHighScoreListener         }     ) end gc.init("gamecenter"); square = widget.newButton{ defaultFile = "square.png",--any object overFile = "square-over.png",--any object label = "To Tap", width = 64, height = 64, onRelease = handleButton } square.x, square.y = \_W\*0.5, \_H\*0.5; leaderboard = widget.newButton{ defaultFile = "leaderboard.png",--any object overFile = "leaderboard-over.png",--any object label = "leaderboard", width = 92, height = 46, onRelease = showLeaderboards } leaderboard.x, leaderboard.y = \_W\*0.5, \_H\*0.5 + leaderboard.height\*1.5; text = display.newText("0", 0, 0, native.systemFontBold, 20); text.x, text.y = \_W\*0.5, \_W\*0.5 - text.height\*5;

Bob, regardless of it, the first submitted score 50 was overriden by 25. Besides, after the score “25” took place within the leaderboard, any higher value than that is not submitted.

I just have to ask the very obvious question.  Are you sure your leaderboard is setup right?  What you are describing is a setting where lower scores are better.

Rob

1 Like

You touched the wound and I found it, Bob. A little mistake just the way you’ve suggested. I thought that wasn’t a configuration issue because @torbenratzlaff said he was getting the same issue even after being able to submit a score.

Thank you, Brent and Bob. And sorry for delaying the final solution to that issue for a lack of attention.

1 Like