GKChallenge

Inherits: RefCounted < Object

Inherited By: GKAchievementChallenge, GKScoreChallenge

Represents a Game Center challenge sent between players.

Description

Base wrapper for challenge objects delivered by Game Center. Use load_received_challenges() to fetch outstanding challenges for the local player, inspect state and challenge_type, and cast to GKScoreChallenge or GKAchievementChallenge when you need type-specific data.

Properties

int

challenge_type

2

float

completion_date

0.0

float

issue_date

0.0

GKPlayer

issuing_player

null

String

message

""

GKPlayer

receiving_player

null

int

state

0

Methods

void

decline()

void

load_received_challenges(callback: Callable) static


Enumerations

enum ChallengeState: 🔗

ChallengeState INVALID = 0

The challenge is invalid or no longer available.

ChallengeState PENDING = 1

The challenge has been issued and is waiting for completion.

ChallengeState COMPLETED = 2

The receiving player completed the challenge.

ChallengeState DECLINED = 3

The receiving player declined the challenge.


enum ChallengeType: 🔗

ChallengeType SCORE = 0

A score-based challenge backed by GKScoreChallenge.

ChallengeType ACHIEVEMENT = 1

An achievement-based challenge backed by GKAchievementChallenge.

ChallengeType UNKNOWN = 2

A challenge payload type that this wrapper does not recognize.


Property Descriptions

int challenge_type = 2 🔗

  • int get_challenge_type()

The challenge payload type. See ChallengeType.


float completion_date = 0.0 🔗

  • float get_completion_date()

Unix timestamp (seconds) when the challenge was completed, or 0 if incomplete.


float issue_date = 0.0 🔗

  • float get_issue_date()

Unix timestamp (seconds) when the challenge was issued.


GKPlayer issuing_player = null 🔗

The player who issued this challenge.


String message = "" 🔗

  • String get_message()

Optional challenge message from the issuing player.


GKPlayer receiving_player = null 🔗

The player who received this challenge.


int state = 0 🔗

  • int get_state()

The current lifecycle state. See ChallengeState.


Method Descriptions

void decline() 🔗

Declines this challenge.


void load_received_challenges(callback: Callable) static 🔗

Loads the challenges currently received by the local player. The callback receives (Array[GKChallenge] challenges, Variant error). If error is not null, it contains a GKError.