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:
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.
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.
Call
TGameService.Initialize. You usually do it fromTCastleApplication.OnInitialize. TheTGameService.Initializemust be called before calling any other method of this class.Call other methods of this class as you see fit – to manage achievements, leaderboards and so on.
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,
AchievementorSubmitScoreorSaveGameLoadorSaveGameSave. You should always make sure that the user is signed-in before calling them. To do this, pass AutoStartSignInFlow parameter asTruetoInitializeor call theRequestSignedIn. And then wait for theStatusproperty to change to gsSignedIn (you can registerOnStatusChangedto 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.