GKMatchmakerViewController¶
Inherits: RefCounted < Object
Presents Apple’s Game Center matchmaking UI.
Description¶
Use this helper to show the stock GKMatchmakerViewController workflow described in GameCenterGuide.md. You can either create and present the controller manually for full control or call request_match() for the convenience flow demonstrated in the guide. See Apple’s GKMatchmakerViewController reference for Apple’s API documentation.
Convenience usage from the guide:
var request := GKMatchRequest.new()
request.max_players = 2
request.min_players = 1
request.invite_message = "Join me in a quest to fun"
GKMatchmakerViewController.request_match(request, func(game_match: GKMatch, error: Variant) -> void:
if error:
print("Could not request a match %s" % error)
else:
print("Match ready")
# Store game_match and connect to its signals as needed.
)
Methods¶
create_controller(request: GKMatchRequest) static |
|
void |
present() |
void |
request_match(request: GKMatchRequest, callback: Callable) static |
Signals¶
Emitted when the user cancels the matchmaking UI. The string is empty on UIKit and contains an informational message on macOS.
did_find_hosted_players(arg1: Array) 🔗
Fired when GameKit returns players for a hosted-server scenario. The array contains GKPlayer instances.
did_find_match(arg1: GKMatch) 🔗
Triggered when a peer-to-peer match has been found and is ready to start.
failed_with_error(arg1: String) 🔗
Emitted if Apple reports an error while matchmaking. The string contains localizedDescription.
Method Descriptions¶
GKMatchmakerViewController create_controller(request: GKMatchRequest) static 🔗
Builds a wrapper around Apple’s view controller for the supplied GKMatchRequest. Configure the returned object and call present() to display it.
void present() 🔗
Presents the previously created view controller, handling both UIKit and AppKit dialog flows.
void request_match(request: GKMatchRequest, callback: Callable) static 🔗
Shows the matchmaking UI and invokes the callback with (GKMatch match, Variant error) where only one argument is non-null. Errors are reported as strings such as “cancelled” when the user dismisses the sheet.