Hi @Wiler Jr,
I did some more testing and everything seems to be working for me. I set up a very basic increment of a score which is assigned to a Composer variable (so basically, it’s just known throughout my code because it’s part of the core Composer table). This simply uses a standard button – widget.newButton() or whatever you want – to increment the score by 25 on each tap. When I do this, I’m seeing the result update instantly in Game Center, and it shows in the Sandbox leaderboard.
[lua]
local composer = require( “composer” )
– Create a Composer variable named “currentScore” with value of 0
composer.setVariable( “currentScore”, 0 )
– Listener function for submission of high score
local function setHighScoreListener( event )
print(“setHighScore-----------------------------------------------------------”)
print_r( event )
end
– Button handler function
local function handleButton( event )
– Increment “currentScore” by 25
composer.setVariable( “currentScore”, composer.getVariable( “currentScore” ) + 25 )
– Submit new “currentScore” to Game Center leaderboard with ID of “1” in iTunes Connect
gameNetwork.request( “setHighScore”,
{
localPlayerScore = { category=“1”, value=composer.getVariable( “currentScore” ) },
listener = setHighScoreListener
}
)
end
[/lua]
A few notes:
-
For “localPlayerScore”, the “category” of “1” is my leaderboard ID within iTunes Connect. Obviously this should be a more descriptive name, but I’m using that for testing.
-
In the “setHighScoreListener()” function, the “print_r” function refers to that shown in the tutorial on printing table contents. I really suggest you use this, as it will dig deep down into a table and all of its sub-tables to show you the values, and that’s especially important for things like Game Center where tables usually have various child tables, and values within those tables which you’ll need to check. LINK: http://coronalabs.com/blog/2014/09/02/tutorial-printing-table-contents/
So, please see if your code compares to this. It’s really simple and it works fine for me.
Thanks,
Brent