GKMatchRequest

Inherits: RefCounted < Object

Configures how many players Game Center should recruit for a realtime match.

Description

Instantiate GKMatchRequest, set the minimum/maximum player counts and invite message, then either create a GKMatchmakerViewController (for full UI control) or call GKMatchmakerViewController.request_match() as shown in GameCenterGuide.md. The optional MatchType argument lets you switch between peer-to-peer, hosted, or turn-based matchmaking. Apple’s guide is at Apple’s GKMatchRequest reference.

Configuration snippet 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"

var max_supported := GKMatchRequest.max_players_allowed_for_match(GKMatchRequest.MatchType.peerToPeer)
print("Peer-to-peer supports up to %d players" % max_supported)

Properties

int

default_number_of_players

0

String

invite_message

""

int

max_players

2

int

min_players

2

Methods

int

max_players_allowed_for_match(forType: int) static


Enumerations

enum MatchType: 🔗

MatchType peerToPeer = 0

There is currently no description for this enum. Please help us by contributing one!

MatchType hosted = 1

There is currently no description for this enum. Please help us by contributing one!

MatchType turnBased = 2

There is currently no description for this enum. Please help us by contributing one!


Property Descriptions

int default_number_of_players = 0 🔗

  • void set_default_number_of_players(value: int)

  • int get_default_number_of_players()

Default number of players your UI suggests when presenting the matchmaking sheet.


String invite_message = "" 🔗

  • void set_invite_message(value: String)

  • String get_invite_message()

Optional text Apple shows when the player sends invitations (see the invite_message example in the guide).


int max_players = 2 🔗

  • void set_max_players(value: int)

  • int get_max_players()

Maximum desired players in the match.


int min_players = 2 🔗

  • void set_min_players(value: int)

  • int get_min_players()

Minimum player count required before the match can start.


Method Descriptions

int max_players_allowed_for_match(forType: int) static 🔗

Returns Apple’s maximum supported player count for the supplied match type (peer_to_peer, hosted, or turn_based).