Gamecenter (For iOS, tvOS, and macOS)

Gamecenter

View and activate on the Corona Store

This plugin allows to control leaderboards, achievements, and challenges on iOS, macOS, or tvOS

Documentation

Before any one asks there is not way to test on macOS except publishing to app store. Please test on iOS (or apple tv). It should function the same, just make sure you set up and put in the right identifier.

TvOS:

https://youtu.be/22a-Vbht6qo

MacOs: (note had someone at corona test the plugin and got screen shots(on corona simulator via Xcode))
slack-imgs.com.png?raw=1

pasted_image_at_2016_11_09_01_51_pm_720.
pasted_image_at_2016_11_15_11_29_pm.png?
^(note old version says “untitled”, the latest now says “gamecenter”

Please note an update in docs. In short , Apple does not have a leaderboard to show so calling leaderboards.show just shows the achievements pop up. You should just make your own leaderboard pop (via display objects and loadScores API)

Update dec 3

iPhone simulator support and bug fixes to leaderboard pop up on iOS

Hi, Scott.

Thank you for this plugin, this really works for my tvOS app, but i have a small question:

How can i configure leaderboard list range?

I have tried set rangeMin and rangeMax to 1 and 100, but everytime i got a list of only 25 items.

gc.leaderboards.loadScores(leaderboardId, lis, {timeScope = “all”, playerScope= “global”, rangeMin=1, rangeMax=100})

working on a fix for this

I just pushed out a fix for this, please try again in an hour (which is how long the plugin system takes to process updates)

Thank you, now it’s working fine.

Help! Why can’t I load up the Game Center?
I’m trying to start-up the gamecenter using the docs and info I’ve found online. What am I doing wrong? I’m getting Runtime error: ERROR: Could not load provider (gamecenter) due to the following reason: module ‘Corona-Provider.gameNetwork.gamecenter’ not found: resource (CoronaProvider:gameNetwork.gamecenter.lu) does not exist in archive no field package.preload['Corona-Provider.gameNetwork.gamecenter"] no file '/var/containers/Bundle/Application/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx/ etc…

Here is my build.settings:

    plugins = {

     [“plugin.gamecenter”] = { publisherId = “tech.scotth” },

}

in my game:

elseif t==“applicationStart” then
    gameNetwork=require(“gameNetwork”)
    local loggedIntoGC = false

    local function initCallback(event)
      if event.type==“showSignIn” then
        – This is an opportunity to pause your game or do other things you might need to do while the Game Center Sign-In controller is up.
      elseif event.data then
        loggedIntoGC=true
        native.showAlert(“Success Test for Game Center Login!”,"",{“OK”})
      end

    end
    gameNetwork.init(“gamecenter”,initCallback)
    return true
  end

From what I can tell, the gameCenter documentation on Scott’s page is different than in the Corona API documentation - so perhaps this should be updated. This works for me on Mac OS, but I’m assuming it will also work on iOS. The init code is as simple as follows:

(extracted from: https://scotth.tech/plugin-gamecenter) local gc = require "plugin.gamecenter" gc.init(function(e) print("init") print("----------") print(json.encode(e)) print("----------") if(e.status == "signed in") then end end)

 

Okay, I really need help now.
The Corona documentation showed that to access the GameCenter, I would use this code:

gamecenter.request((“init”,{listener=requestCallback})
 

But the new documentation has changed so that if I want to init, I use:
gamecenter.init(callback)

So the question is, hiow can I call the game center to loadLocalPlayer?

Based upon the previous documentation, I could just:
gamecenter.request((“loadLocalPlayer”,{listener=requestCallback})

But with the new changes, I don’t see a gamecenter.loadLocalPlayer function. Please help!

Also, when I do the new init, the json.encode(e) displays the following:
{“status”:“signed in”,“type”:“login”,“name”:“gamecenter”}

Isn’t “name” suppose to return the name of the player that has “signed in”?

If not, this brings to the forefront the serious need to retrieve the localPlayer’s information - like his name and photo, at the least. Please help.

I also discovered that since iOS 9, there is no “Sandbox” to enable on in my Settings -> Game Center of my iOS device. I found this issue discussed AND solved here: https://stackoverflow.com/questions/34055758/ios9-this-game-is-not-recognized-by-game-center

But I still need to know how to loadLocalPlayer, or its unusable.

(SOLVED) Well, combing through the newest documentation from Scott H, I did find “gc.player – handles player data”. Doing a search on this documentation page for loadLocalPlayer (the term used in the Game Center documentation) doesn’t show any results and is why I encountered this problem; hense the last several posts.

@Scott, you might want to make some references in your documentation to the Game Center equivilents. I think this may save others (like me) time when implementing this.

I just came across an online comment that since iOS 9, iOS Game Center photos have been killed server-side. I’m guessing this is why Scott’s latest version does not include the photo info.

Hi,

using the plugin on macOS I get the message attached.

Is there a way to avoid or localize it?

Thanks,

Tobias

Try using gc.player.id() to check if signed in, if nil you need to gc.init