Greetings, I’ve been adding the last touches for my upcoming game app, but I’m stuck with integrating game center to it.
I have made a button (gameCenterButton) appear after the player dies, what I want is when the player clicks on it, I want GameCenter to show a leaderboard, but it’s not working, I’m sure I’ve done it wrong, I came for help
The code:
----------- \*\* those are written at the very beginning of the code ----------- local gameNetwork = require ( "gameNetwork" ) local loggedIntoGC = false ----------- local gameCenterButton = display.newImageRect(gameGroup, "assets/game\_center.png", 80, 50) -- gamecenter button gameCenterButton.x = \_W / 2 + 250 gameCenterButton.y = \_H / 2 + 110 gameCenterButton.alpha = 0 gameCenterButton:addEventListener("touch", gameCenter) -- gamecenter button touch event gameCenter = function( event ) local t = event.target if event.phase == "began" then display.getCurrentStage():setFocus( t ) t.isFocus = true t.alpha = 0.5 elseif t.isFocus then if event.phase == "ended" then display.getCurrentStage():setFocus( nil ) t.isFocus = false t.alpha = 1 --Check bounds. If we are in it then click! local b = t.contentBounds if event.x \>= b.xMin and event.x \<= b.xMax and event.y \>= b.yMin and event.y \<= b.yMax then -- Hide the ad hideAdMobAd() -- called after the "init" request has completed 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 local function onSystemEvent( event ) if event.type == "applicationStart" then gameNetwork.init( "gamecenter", initCallback ) return true end end Runtime:addEventListener( "system", onSystemEvent ) gameNetwork.show("leaderboards", { leaderboard = { timeScope = "Week"}}) end end end end
A few questions I would like to ask;
- Is the gamecenter fully implemented in corona only, or I have to do some things in “iTunes Connect”?
- What is “sandbox mode” ?
I would appreciate your help