All Projects → MrStahlfelge → Gdx Gamesvcs

MrStahlfelge / Gdx Gamesvcs

Licence: apache-2.0
Easy integration of gameservices in your libGDX game: Google Play Games, Apple Game Center, Amazon GameCircle and more

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Gdx Gamesvcs

Libgdx
Desktop/Android/HTML5/iOS Java game development framework
Stars: ✭ 19,420 (+21008.7%)
Mutual labels:  libgdx
Hook
A RESTful and extendable Backend as a Service that provides instant backend to develop sites and apps faster, with dead-simple integration for JavaScript, iOS, Android and more.
Stars: ✭ 761 (+727.17%)
Mutual labels:  baas
Local Development
[Deprecated] Run Hasura locally on your computer
Stars: ✭ 38 (-58.7%)
Mutual labels:  baas
Skygear Server
Skygear - an open source serverless platform for modern secure app development
Stars: ✭ 380 (+313.04%)
Mutual labels:  baas
Appwrite
Appwrite is a secure end-to-end backend server for Web, Mobile, and Flutter developers that is packaged as a set of Docker containers for easy deployment 🚀
Stars: ✭ 14,592 (+15760.87%)
Mutual labels:  baas
Gdx Ai
Artificial Intelligence framework for games based on libGDX or not. Features: Steering Behaviors, Formation Motion, Pathfinding, Behavior Trees and Finite State Machines
Stars: ✭ 907 (+885.87%)
Mutual labels:  libgdx
Gdx Texture Packer Gui
A simple way to pack and manage texture atlases for LibGDX game framework.
Stars: ✭ 371 (+303.26%)
Mutual labels:  libgdx
Planet Generator
Generates random, pixel planets. Built in LibGDX. Inspired by https://managore.itch.io/planetarium
Stars: ✭ 56 (-39.13%)
Mutual labels:  libgdx
Vis Ui
libGDX UI toolkit
Stars: ✭ 547 (+494.57%)
Mutual labels:  libgdx
Terrarum Sans Bitmap
The real multilingual bitmap font for video games
Stars: ✭ 34 (-63.04%)
Mutual labels:  libgdx
Mini2dx
A high-level cross-platform 2D game development API
Stars: ✭ 384 (+317.39%)
Mutual labels:  libgdx
End
a Node.js Realtime BaaS like Firebase by Socket.io and MongoDB
Stars: ✭ 481 (+422.83%)
Mutual labels:  baas
Cocos Ui Libgdx
a ui library of ligdx with cocostudio 一个cocostudio的ui解析库
Stars: ✭ 25 (-72.83%)
Mutual labels:  libgdx
Parse Server
API server module for Node/Express
Stars: ✭ 19,165 (+20731.52%)
Mutual labels:  baas
Quilly S Adventure
A little adventure game written in Kotlin using LibGDX,LibKTX,Box2D and Ashley
Stars: ✭ 47 (-48.91%)
Mutual labels:  libgdx
Gdx Skins
Free LibGDX Scene2D GUI skins
Stars: ✭ 373 (+305.43%)
Mutual labels:  libgdx
Chemtris
an interactive 3D game that teaches Chemistry in a fun way
Stars: ✭ 19 (-79.35%)
Mutual labels:  libgdx
Syncano Node
Syncano Toolkit for JavaScript development
Stars: ✭ 61 (-33.7%)
Mutual labels:  baas
Ionic Parse Server
Starter for integrating Ionic 3, Angular 4+ and Parse Server
Stars: ✭ 50 (-45.65%)
Mutual labels:  baas
Ktx
LibKTX: Kotlin extensions for LibGDX games and applications
Stars: ✭ 913 (+892.39%)
Mutual labels:  libgdx

gdx-gamesvcs

Framework and implementations for using Game Services (BaaS) with libGDX.

Build Status Maven Central

Demo app

With this extension, you can integrate one or more Game Services in your libGDX games with ease. You can choose the wanted Game Service client in your Launcher classes dynamically.

Supported game services

Basic concept

The library provides an interface IGameServiceClient that you reference in your core code. Your platform-dependant launchers instantiate an actual implementation of the interface.

Every 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.

There is a no-op implementation NoGameServiceClient provided that does absolutely nothing besides logging your calls. Use it to test platform-independant or to avoid null checks or NPEs. For testing your UI's behaviour on slow callback responses, you can use MockGameServiceClient.

See the corresponding demo app for an example and this project's wiki for further documentation.

Working demos

Ready to play:

Source examples:

Installation

This project is published to the Sonatype Maven repository. You can integrate the lib into your project by just adding the dependencies to your build.gradle file.

Define the version of this API right after the gdxVersion:

gdxVersion = '1.9.8'
gamesvcsVersion = '1.1.0'

Core:

compile "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:$gamesvcsVersion"

For the HTML5 project, you also have to include the sources

compile "de.golfgl.gdxgamesvcs:gdx-gamesvcs-core:$gamesvcsVersion:sources"

and add a line to GdxDefinition.gwt.xml and GdxDefinitionSuperdev.gwt.xml:

<inherits name="de.golfgl.gdxgamesvcs.gdx_gamesvcs_gwt" />

After 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 or implement your own client against IGameServiceClient.

Building from source

To 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:

gradlew clean uploadArchives -PLOCAL=true

See build.gradle file for current version to use in your dependencies.

Usage

Initializing the game service client

You should be fine by adding the following lines to your game in order to connect to the service:

Main game class:

public IGameServiceClient gsClient;

@Override
public void create() {
    // ...awesome initialization code...
    
    if (gsClient == null)
        gsClient = new NoGameServiceClient();

    // for getting callbacks from the client
    gsClient.setListener(this);

    // establish a connection to the game service without error messages or login screens
    gsClient.resumeSession();
    
}

@Override
public void pause() {
    super.pause();

    gsClient.pauseSession();
}

@Override
public void resume() {
    super.resume();

    gsClient.resumeSession();
}

In the launcher class you instantiate and initialize the GameServiceClient for the service you want to use:

    DesiredGameserviceClient gsClient = new DesiredGameserviceClient();

    gsClient.initialize( game service dependant initialization parameters );

    myGdxGame.gsClient = gsClient;

Initialization depends on the game service; see the wiki pages on how to instantiate the included Game Service clients.

As 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.

If you want to know if you established a connection to a user session, you can use gsClient.isSessionActive(), or set a listener and wait for the call to gsOnSessionActive(). You don't need to check if a user session is active for submitting scores, events and unlocking achievements, as some game services allow anonymous or guest submits. The API client implementations do all needed checks.

Submitting events and scores, unlocking achievements

You can feed your players by unlocking achievements and posting scores to leaderboards really easy:

gsClient.submitToLeaderboard(leaderboardId, score, tag);

gsClient.unlockAchievement(achievementId);

Events are interesting for you as a developer.

gsClient.submitEvent(eventId, 1);

Please 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.

Cloud save

Not 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

if (gsClient.isFeatureSupported(GameServiceFeature.GameStateStorage))

If you ensured that cloud save feature is available, use these methods to invoke it:

gsClient.loadGameState(fileId, new ILoadGameStateResponseListener() {...});

gsClient.saveGameState(fileId, gameState, progressValue, 
                       new ISaveGameStateResponseListener() {...});

The methods perform an ansynchronous operation and call your listener afterwards.

Fetching scores and achievement status

The interface provides a method for open up an API's default leaderboard or achievment UI:

gsClient.providesAchievementsUI();
gsClient.showAchievements();
// same for leaderboards

Default UI is provided by all game services, so you need to check with gsClient.isFeatureSupported() before calling.

Fetching scores and achievement status to show in your own UI can be done by calling

 gsClient.fetchLeaderboardEntries(...)
 gsClient.fetchAchievements(...)

after checking

 gsClient.isFeatureSupported(GameServiceFeature.FetchLeaderBoardEntries)
 gsClient.isFeatureSupported(GameServiceFeature.FetchAchievements))

You give a listener as a parameter which will be called with a list of achievement or leader board entries in response. See to the JavaDocs or the demo application for more information.

Explicit log in and out

Some 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.

Note: For Google Play Games your game even must provide a sign in/out button to be considered Google Play Games Services-compatible.

News & Community

You can get help on the libgdx discord.

License

The 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!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].