GKLocalPlayer¶
Inherits: GKPlayer < RefCounted < Object
Represents the signed-in Game Center player and exposes local-only APIs.
Description¶
Use GKLocalPlayer to inspect authentication flags and to fetch the local player’s friends as shown in the “Players” section of GameCenterGuide.md. Every asynchronous call mirrors Apple’s API and invokes your Callable with the requested data plus an optional error Variant. Refer to Apple’s documentation at Apple’s GKLocalPlayer reference for platform-specific behavior.
Sample from the guide that fetches the local player when your scene loads:
var game_center: GameCenterManager
var local: GKLocalPlayer
func _ready() -> void:
game_center = GameCenterManager.new()
local = game_center.local_player
print("ONREADY: local, is auth: %s" % local.is_authenticated)
print("ONREADY: local, player ID: %s" % local.game_player_id)
Friends-related helpers mirror the snippets in the guide (assuming you stored the player reference in local):
# Loads the local player's friends list if access is granted.
local.load_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
if error:
print(error)
else:
for friend in friends:
print(friend.display_name)
)
# Loads players the local user can challenge.
local.load_challengeable_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
if error:
print(error)
else:
for friend in friends:
print(friend.display_name)
)
# Loads the friends or recent players list.
local.load_recent_friends(func(friends: Array[GKPlayer], error: Variant) -> void:
if error:
print(error)
else:
for friend in friends:
print(friend.display_name)
)
Properties¶
|
||
|
||
|
||
|
Methods¶
void |
delete_saved_games(named: String, callback: Callable) |
void |
fetch_items_for_identity_verification_signature(callback: Callable) |
void |
fetch_saved_games(callback: Callable) |
void |
load_challengeable_friends(callback: Callable) |
void |
load_friends(callback: Callable) |
void |
load_recent_friends(callback: Callable) |
void |
save_game_data(data: PackedByteArray, withName: String, callback: Callable) |
Property Descriptions¶
bool is_authenticated = false 🔗
bool get_is_authenticated()
Reflects GKLocalPlayer.local.isAuthenticated.
bool is_multiplayer_gaming_restricted = true 🔗
bool get_is_multiplayer_gaming_restricted()
True when multiplayer is disabled by parental controls.
bool is_personalized_communication_restricted = true 🔗
bool get_is_personalized_communication_restricted()
Indicates whether personalized communication is blocked for this account.
bool get_is_underage()
Apple’s isUnderage flag for COPPA-compliant flows.
Method Descriptions¶
void delete_saved_games(named: String, callback: Callable) 🔗
There is currently no description for this method. Please help us by contributing one!
void fetch_items_for_identity_verification_signature(callback: Callable) 🔗
Calls Apple’s fetchItems helper for server-side authentication. The callback receives (Dictionary data, Variant error). The dictionary contains the url, data, salt, and timestamp keys described in the inline Swift documentation, letting your backend verify the player’s identity.
void fetch_saved_games(callback: Callable) 🔗
Use this API to retrieve the list of saved games, upon completion, this
method invokes the provided callback with both an array of GKSavedGame objects
and a variant error, if not nil it contains a string describing the problem.
void load_challengeable_friends(callback: Callable) 🔗
Loads players whom the local user can challenge. The callback receives (Array[GKPlayer] friends, Variant error) where either argument can be null.
void load_friends(callback: Callable) 🔗
Fetches the friends list. The callback receives (Array[GKPlayer] friends, Variant error); a non-null error Variant holds the localized error string.
void load_recent_friends(callback: Callable) 🔗
Loads friends that recently played together with the local player. The callback signature matches load_challengeable_friends().
void save_game_data(data: PackedByteArray, withName: String, callback: Callable) 🔗
Saves the packed byte array as the game data with the specified name, upon
completion the callback is invoked with both a GKSavedObject parameter and
a Variant parameter for the error. The GKSavedObject is not-nil on success,
and on error, the second parameter is not-nil and contains the error message.