Hi Brent,
Sure.
Logic from main.lua
[lua]
local leaderboardiOSId = “example_world_rankings”
local leaderboardAndroidId = “AbCDeFGHiJkLm”
local leaderboardAmazonId = “world_rankings”
if (leaderboardiOSId and leaderboardAndroidId) then
local gc = require( “libs.gc” )
gc.init({
iOS=leaderboardiOSId,
android=leaderboardAndroidId,
amazon=leaderboardAmazonId,
isAmazon=isAmazon
})
end
[/lua]
libs.gc - libs/gc.lua
[lua]
local gameNetwork = require “gameNetwork”
local helper = require(“libs.helper”)
local loggedIntoGC = false
local androidLeaderboardId = “”
local iOSLeaderboardId = “”
local amazonLeaderboardId = “”
local function initCallback( event )
– “showSignIn” is only available on iOS 6+
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.
– For the iOS 6.0 landscape orientation bug, this is an opportunity to remove native objects so they won’t rotate.
– This is type “init” for all versions of Game Center.
elseif event.data then
loggedIntoGC = true
end
end
local function onSystemEvent( event )
if event.type == “applicationStart” then
if helper.isAndroid then
gameNetwork.init( “google”, initCallback )
gameNetwork.request(“login”,{userInitiated = true})
else
gameNetwork.init( “gamecenter”, initCallback )
end
return true
end
end
–[[example
Runtime:dispatchEvent({name=“gc”, cmd=“setHighScore”, value=25})
Runtime:dispatchEvent({name=“gc”, cmd=“showLeaderboard”})
]]
local function onGameCenterEvent(event)
if event.cmd == “showLeaderboard” then
if (gamecircle) then
gamecircle.Leaderboard.OpenOverlay(amazonLeaderboardId)
else
gameNetwork.show( “leaderboards”, { leaderboard = {timeScope=“Week”}, listener=onGameNetworkPopupDismissed } )
end
elseif(event.cmd == “setHighScore”) then
if (gamecircle) then
gamecircle.Leaderboard.SubmitScore(amazonLeaderboardId, event.value)
else
local category = iOSLeaderboardId
if (helper.isAndroid) then category = androidLeaderboardId end
gameNetwork.request( “setHighScore”, {
localPlayerScore = { category = category, value = event.value },
listener = onGameNetworkRequestResult,
})
end
end
end
local M = {};
function M.init(params)
iOSLeaderboardId = params.iOS or “”
androidLeaderboardId = params.android or “”
amazonLeaderboardId = params.amazon or “”
if params.isAmazon then
gamecircle = require(“plugin.gamecircle”)
gamecircle.Init(false, true, false) – false true false means - achievements, leaderboards, whispersync
end
Runtime:addEventListener( “system”, onSystemEvent )
Runtime:addEventListener( “gc”, onGameCenterEvent)
end
return M;
[/lua]
Settings file - XXXX replacing real Ids for privacy reasons
[lua]
settings = {
orientation =
{
default = “landscapeLeft”,
supported =
{
“landscapeRight”,
},
},
android = {
usesPermissions = {
‘android.permission.INTERNET’,
‘android.permission.ACCESS_NETWORK_STATE’,
“android.permission.ACCESS_WIFI_STATE”,
“android.permission.READ_PHONE_STATE”
},
googlePlayGamesAppId = “XXXXXXXXXXXX”, – Your Google Play Games App Id
},
plugins =
{
[“CoronaProvider.ads.admob”] =
{
publisherId = “com.coronalabs”
},
[“plugin.google.play.services”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { android = true }
},
[“CoronaProvider.gameNetwork.google”] = {
publisherId = “com.coronalabs”,
supportedPlatforms = { android = true }
},
[“facebook”] = {
publisherId = “com.coronalabs”,
},
[“CoronaProvider.analytics.flurry”] =
{
publisherId = “com.coronalabs”,
},
[“CoronaProvider.gameNetwork.apple”] =
{
publisherId = “com.coronalabs”,
supportedPlatforms = { iphone=true, [“iphone-sim”]=true },
},
[“plugin.gamecircle”] =
{
– required
publisherId = “COM_INNOVATIVELEISURE”,
supportedPlatforms = { [“android-kindle”] = true },
},
},
iphone = {
plist = {
CFBundleIconFiles = {
“Icon.png”,
“Icon@2x.png”,
“Icon-72.png”,
“Icon-72@2x.png”,
“Icon-Small-50.png” ,
“Icon-Small-50@2x.png” ,
“Icon-Small.png” ,
“Icon-Small@2x.png”,
“Icon-Small-40.png”,
“Icon-Small-40@2x.png”,
“Icon-76.png”,
“Icon-76@2x.png”,
“Icon-60.png”,
“Icon-60@2x.png”,
},
UIAppFonts =
{
“pixel.ttf”
},
CFBundleShortVersionString = “1.0”,
UIApplicationExitsOnSuspend = false,
FacebookAppID = ‘XXXXXXXXXXXX’, --replace XXXXXXXXXX with your Facebook App ID
CFBundleURLTypes = {
{
CFBundleURLSchemes = { ‘fbXXXXXXXXXXXX’, }
}
}
},
},
}
[/lua]
Thanks a lot for your help.