Skip to content
GGGameCentre makes working with Game Center nice and easy.
Lua
Find file

README.md

GGGameCentre

GGGameCentre makes working with Game Center nice and easy.

Basic Usage

Require The Code
local GGGameCentre = require( "GGGameCentre" )
Create your new game center manager
local gameCentre = GGGameCentre:new()
Show the achievements dialog
gameCentre:showAchievements()
Show the leaderboards dialog
gameCentre:showLeaderboards()
Show a specific leaderboard
gameCentre:showLeaderboards( "com.game.leaderboard" )
Show a specific leaderboard for today
gameCentre:showLeaderboards( "com.game.leaderboard", GGGameCentre.TimeScope.Today )
Show the friend request dialog
gameCentre:requestFriends()
Show the friend request dialog for a specific friend and include a message
gameCentre:requestFriends( "Will you be my friend?", 12345678 )
Show the friend request dialog for two friends and include a message
gameCentre:requestFriends( "Will you be my friend?", { "G:12345678", "G:64826483" } )
Show the friend request dialog for a specific friend via email addresses and include a message
gameCentre:requestFriends( "Will you be my friend?", nil, "me@me.com" )
Show the friend request dialog for two friends via email addresses and include a message
gameCentre:requestFriends( "Will you be my friend?", nil, { "me@me.com", "bob@me.com" } )
Check if the player is logged in
local loggedIn = gameCentre:isLoggedIn()
Set a new highscore.
gameCentre:setHighScore( "com.game.leaderboard", 25 )
Unlock an achievement.
gameCentre:unlockAchievement( "com.game.achievement1" )
Partly unlock an achievement.
gameCentre:unlockAchievement( "com.game.achievement2", 50 )
Reset all achievements.
gameCentre:resetAchievements()
Load the local player.
local listener = function( event )
    if event.phase == "loadLocalPlayer" then
        print( event.player.playerID )
    end
end

local gameCentre = GGGameCentre:new( listener )

gameCentre:loadLocalPlayer()
Get the local player after it has already been loaded.

local player = gameCentre:getLocalPlayer()


##### Load the friends of the local player.
```lua
local listener = function( event )
    if event.phase == "loadFriends" then
        print( event.freinds[ 1 ].playerID )
    end
end

local gameCentre = GGGameCentre:new( listener )

gameCentre:loadFriends()
Get the friends of the local player after it has already been loaded.

local friends = gameCentre:getFriends()


##### Destroy this GGGameCentre object
```lua
gameCentre:destroy()
Something went wrong with that request. Please try again.