Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

Gamecenter (For iOS, tvOS, and macOS)
Started by Scott Harrison Nov 15 2016 10:30 PM

15 replies to this topic
[TOPIC CONTROLS]
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#1

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

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"

[TOPIC: post.html]
#2

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

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)

[TOPIC: post.html]
#3

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

Update dec 3

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



[TOPIC: post.html]
#4

Vitaliy Latypov

[GLOBAL: userInfoPane.html]
Vitaliy Latypov
  • Enthusiast

  • 53 posts
  • Corona SDK

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})



[TOPIC: post.html]
#5

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

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



[TOPIC: post.html]
#6

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

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)



[TOPIC: post.html]
#7

Vitaliy Latypov

[GLOBAL: userInfoPane.html]
Vitaliy Latypov
  • Enthusiast

  • 53 posts
  • Corona SDK

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.



[TOPIC: post.html]
#8

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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



[TOPIC: post.html]
#9

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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)
 

[TOPIC: post.html]
#10

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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!



[TOPIC: post.html]
#11

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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.



[TOPIC: post.html]
#12

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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.



[TOPIC: post.html]
#13

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

(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.



[TOPIC: post.html]
#14

troylyndon

[GLOBAL: userInfoPane.html]
troylyndon
  • Contributor

  • 607 posts
  • Corona SDK

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.



[TOPIC: post.html]
#15

Tobias Mueller

[GLOBAL: userInfoPane.html]
Tobias Mueller
  • Enthusiast

  • 66 posts
  • Corona SDK

Hi,

 

using the plugin on macOS I get the message attached.

Is there a way to avoid or localize it?

 

Attached File  Bildschirmfoto 2018-11-01 um 11.17.27.png   27.32KB   0 downloads

 

Thanks,

Tobias

 

 



[TOPIC: post.html]
#16

Scott Harrison

[GLOBAL: userInfoPane.html]
Scott Harrison
  • Corona Geek

  • 1,795 posts
  • Enterprise

Hi,

 

using the plugin on macOS I get the message attached.

Is there a way to avoid or localize it?

 

attachicon.gifBildschirmfoto 2018-11-01 um 11.17.27.png

 

Thanks,

Tobias

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




[topic_controls]
[/topic_controls]