Class TGameService

Unit

Declaration

type TGameService = class(TComponent)

Description

Integration with a game service, that can be used to show achievements, leaderboards, and store save games "in the cloud". This integrates with

  • Google Play Games on Android

  • Apple Game Center on iOS.

Usage:

  1. Include the necessary integration code in your Android / iOS project.

    For Android, add the "google_play_games" service inside CastleEngineManifest.xml. See Android "google_play_games" service docs.

    For iOS, add the "apple_game_center" service inside CastleEngineManifest.xml. See iOS "apple_game_center" service docs.

  2. Create an instance of this class. Only a single instance of this class makes sense right now, both Android and iOS only allow using a single game service connection from a given game.

  3. Call TGameService.Initialize. You usually do it from TCastleApplication.OnInitialize. The TGameService.Initialize must be called before calling any other method of this class.

  4. Call other methods of this class as you see fit – to manage achievements, leaderboards and so on.

  5. The user must be "signed in" to the game service.

    The methods that display some user-interface will automatically attempt to sign-in the user if needed. These include ShowAchievements, ShowLeaderboard, ShowSaveGames. So you don't have to do anything before you call them.

    All other methods will not sign-in the user automatically. For example, Achievement or SubmitScore or SaveGameLoad or SaveGameSave. You should always make sure that the user is signed-in before calling them. To do this, pass AutoStartSignInFlow parameter as True to Initialize or call the RequestSignedIn. And then wait for the Status property to change to gsSignedIn (you can register OnStatusChanged to be notified about changes).

    Note that some platforms (like new Google Play Games v2) may automatically sign-in the user always. Try not to rely on it, if you want to work in all cases (and with all supported platforms).

Source: services/castlegameservice.pas (line 112).

Hierarchy

  • TObject
  • TPersistent
  • TComponent
  • TGameService

Generated by PasDoc 0.17.0.snapshot.