{"id":13528996,"url":"https://github.com/MrStahlfelge/gdx-gamesvcs","last_synced_at":"2025-04-01T14:33:48.724Z","repository":{"id":43175367,"uuid":"94573500","full_name":"MrStahlfelge/gdx-gamesvcs","owner":"MrStahlfelge","description":"Easy integration of gameservices in your libGDX game: Google Play Games, Apple Game Center, Amazon GameCircle and more","archived":false,"fork":false,"pushed_at":"2025-03-11T14:57:39.000Z","size":2925,"stargazers_count":114,"open_issues_count":7,"forks_count":21,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-03-29T04:02:35.008Z","etag":null,"topics":["baas","gamecenter","gamecircle","gamejolt","gpgs","kongregate","libgdx","playgameservices"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MrStahlfelge.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null},"funding":{"ko_fi":"MrStahlfelge"}},"created_at":"2017-06-16T19:03:22.000Z","updated_at":"2025-03-17T07:55:20.000Z","dependencies_parsed_at":"2024-01-03T03:54:34.466Z","dependency_job_id":"dfa9fd37-08fe-448f-a902-46403da8ca9c","html_url":"https://github.com/MrStahlfelge/gdx-gamesvcs","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrStahlfelge%2Fgdx-gamesvcs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrStahlfelge%2Fgdx-gamesvcs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrStahlfelge%2Fgdx-gamesvcs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MrStahlfelge%2Fgdx-gamesvcs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MrStahlfelge","download_url":"https://codeload.github.com/MrStahlfelge/gdx-gamesvcs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655505,"owners_count":20812646,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["baas","gamecenter","gamecircle","gamejolt","gpgs","kongregate","libgdx","playgameservices"],"created_at":"2024-08-01T07:00:30.814Z","updated_at":"2025-04-01T14:33:43.882Z","avatar_url":"https://github.com/MrStahlfelge.png","language":"Java","funding_links":["https://ko-fi.com/MrStahlfelge"],"categories":["Resources","游戏开发"],"sub_categories":["Services","文件同步"],"readme":"# gdx-gamesvcs\n\nFramework and implementations for using Game Services (BaaS) with libGDX.\n\n[![Build Status](https://travis-ci.org/MrStahlfelge/gdx-gamesvcs.svg?branch=master)](https://travis-ci.org/MrStahlfelge/gdx-gamesvcs)\n![Maven Central](http://maven-badges.herokuapp.com/maven-central/de.golfgl.gdxgamesvcs/gdx-gamesvcs-core/badge.svg)\n\n![Demo app](/assets/gdxgsgpgs.gif?raw=true \"Demo app\")\n\nWith this extension, you can integrate one or more Game Services in your libGDX games with ease.\nYou can choose the wanted Game Service client in your Launcher classes dynamically.\n\n## Supported game services\n\n* [Google Play Games](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/Google-Play-Games) (Android, Desktop, HTML5)\n* [Apple Game Center](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/Apple-Game-Center) (iOS RoboVM)\n* [GameJolt](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/GameJolt) (all platforms)\n* [Huawei Game Service](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/Huawei-Game-Service) (Android, since 1.1.0)\n* [Amazon GameCircle](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/Amazon-GameCircle) (Android)\n* [Kongregate](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki/Kongregate) (HTML5)\n\n\n## Basic concept\n\nThe library provides an interface `IGameServiceClient` that you reference in your core code. Your platform-dependant launchers instantiate an actual implementation of the interface.\n\nEvery implemented game service client has its own project you can decide to include or not. So your game won't get blown up with code you don't need.\n\nThere is a no-op implementation `NoGameServiceClient` provided that does absolutely nothing besides logging your calls. Use it to test platform-independant\nor to avoid `null` checks or NPEs.\nFor testing your UI's behaviour on slow callback responses, you can use `MockGameServiceClient`.\n\nSee the corresponding [demo app](https://github.com/MrStahlfelge/gdx-gamesvcs-app) for an example and this project's wiki for further documentation.\n\n## Working demos\n\nReady to play:\n* Google Play Games: my game [Falling Lightblocks](https://play.google.com/store/apps/details?id=de.golfgl.lightblocks\u0026referrer=utm_source%3Dgh) is using this lib with GPGS on Android. GPGS on HTML is used by [Secret Chronicles Classic Platformer](https://www.kongregate.com/games/MrStahlfelge/secret-chronicles-classic-platformer) on Kongregate.\n* Apple GameCenter: [Falling Lightblocks](https://itunes.apple.com/app/id1453041696), again\n* GameJolt: check out the [HTML5 demo app](http://gamejolt.com/games/gdx-gamesvcs-gj/263351), or web version of my game [Falling Lightblocks](https://gamejolt.com/games/lightblocks/259654)\n* [Kongregate HTML5 demo app](http://www.kongregate.com/games/MrStahlfelge/kongregate-api-for-libgdx-example)\n\nSource examples:\n* [Demo app](https://github.com/MrStahlfelge/gdx-gamesvcs-app)\n* [Falling Lightblocks](https://github.com/MrStahlfelge/lightblocks)\n* [Secret Chronicles Classic](https://github.com/MrStahlfelge/SMC-libgdx)\n\n## Installation\n\nThis project is published to the Sonatype Maven repository. You can integrate the lib \ninto your project by just adding the dependencies to your `build.gradle` file.\n\nDefine the version of this API right after the gdxVersion: \n   \n    gdxVersion = '1.9.8'\n    gamesvcsVersion = '1.1.0'\n\nCore:\n\n    api \"de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:$gamesvcsVersion\"\n    \nFor the HTML5 project, you also have to include the sources\n\n    implementation \"de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:$gamesvcsVersion:sources\"\n\nand add a line to `GdxDefinition.gwt.xml` and `GdxDefinitionSuperdev.gwt.xml`:\n\n    \u003cinherits name=\"de.golfgl.gdxgamesvcs.gdx_gamesvcs_gwt\" /\u003e\n\nAfter including the dependencies and refreshing, you can use the `NoGameServiceClient` in your project. For using another Gameservice, add its dependencies according to its [wiki page](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki) or implement your own client against `IGameServiceClient`.\n\n### Building from source\nTo build from source, clone or download this repository, then open it in Android Studio. Perform the following command to compile and upload the library in your local repository:\n\n    gradlew clean publishToMavenLocal\n    \nSee `build.gradle` file for current version to use in your dependencies.\n\n## Usage\n\n### Initializing the game service client\n\nYou should be fine by adding the following lines to your game in order to connect to the service:\n\nMain game class:\n\n    public IGameServiceClient gsClient;\n    \n    @Override\n    public void create() {\n        // ...awesome initialization code...\n        \n        if (gsClient == null)\n            gsClient = new NoGameServiceClient();\n\n        // for getting callbacks from the client\n        gsClient.setListener(this);\n\n        // establish a connection to the game service without error messages or login screens\n        gsClient.resumeSession();\n        \n    }\n    \n    @Override\n    public void pause() {\n        super.pause();\n\n        gsClient.pauseSession();\n    }\n\n    @Override\n    public void resume() {\n        super.resume();\n\n        gsClient.resumeSession();\n    }\n\nIn the launcher class you instantiate and initialize the GameServiceClient for the service you want to use:\n\n        DesiredGameserviceClient gsClient = new DesiredGameserviceClient();\n\n        gsClient.initialize( game service dependant initialization parameters );\n\n        myGdxGame.gsClient = gsClient;\n\nInitialization depends on the game service; see the [wiki pages](https://github.com/MrStahlfelge/gdx-gamesvcs/wiki) on how to instantiate the included Game Service clients.\n\nAs you see, you assign the game service client dynamically here - so it is no problem to support different game services with only a single build of your game.\n\nIf you want to know if you established a connection to a user session, you can use \n`gsClient.isSessionActive()`, or set a listener and wait for the call to \n`gsOnSessionActive()`. You don't need to check if a user session is active for \nsubmitting scores, events and unlocking achievements, as some game services allow anonymous\nor guest submits. The API client implementations do all needed checks.\n\n### Submitting events and scores, unlocking achievements\n\nYou can feed your players by unlocking achievements and posting scores to leaderboards really easy:\n\n    gsClient.submitToLeaderboard(leaderboardId, score, tag);\n    \n    gsClient.unlockAchievement(achievementId);\n    \nEvents are interesting for you as a developer.     \n    \n    gsClient.submitEvent(eventId, 1);\n\nPlease note: It depends of the game services which calls can be processed without a user session. The API client implementations deal with that so you don't have to.  \n\n### Cloud save\n\nNot every game service and client implementation supports cloud save, check the overview table in the wiki. In your game, you can and must check the availability by calling\n\n    if (gsClient.isFeatureSupported(GameServiceFeature.GameStateStorage))\n\nIf you ensured that cloud save feature is available, use these methods to invoke it:    \n\n    gsClient.loadGameState(fileId, new ILoadGameStateResponseListener() {...});\n\n    gsClient.saveGameState(fileId, gameState, progressValue, \n                           new ISaveGameStateResponseListener() {...});\n\nThe methods perform an ansynchronous operation and call your listener afterwards.\n\n\n### Fetching scores and achievement status\n\nThe interface provides a method for open up an API's default leaderboard or achievment UI:\n\n    gsClient.providesAchievementsUI();\n    gsClient.showAchievements();\n    // same for leaderboards\n\nDefault UI is provided by all game services, so you need to check with `gsClient.isFeatureSupported()` before calling.\n\nFetching scores and achievement status to show in your own UI can be done by calling\n     \n     gsClient.fetchLeaderboardEntries(...)\n     gsClient.fetchAchievements(...)\n     \nafter checking\n    \n     gsClient.isFeatureSupported(GameServiceFeature.FetchLeaderBoardEntries)\n     gsClient.isFeatureSupported(GameServiceFeature.FetchAchievements))\n\nYou give a listener as a parameter which will be called with a list of achievement or leader board \nentries in response. See to the JavaDocs or the demo application for more information.\n\n### Explicit log in and out\nSome game services support user sign in and out, some need the user to log in manually for the first time. Use the game service interface's `logIn()` and `logOut()` methods for doing so. These methods should only be called when the user manually requested an explicit log in/out. \n\nNote: For Google Play Games your game even *must* provide a sign in/out button to be considered Google Play Games Services-compatible.\n\n## News \u0026 Community\n\nYou can get help on the [libgdx discord](https://discord.gg/6pgDK9F).\n\n## License\n\nThe project is licensed under the Apache 2 License, meaning you can use it free of charge, without strings attached in commercial and non-commercial projects. We love to get (non-mandatory) credit in case you release a game or app using this project!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMrStahlfelge%2Fgdx-gamesvcs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FMrStahlfelge%2Fgdx-gamesvcs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FMrStahlfelge%2Fgdx-gamesvcs/lists"}