gdx-gamesvcs | Easy integration of gameservices in your libGDX game | Game Engine library
kandi X-RAY | gdx-gamesvcs Summary
Support
Quality
Security
License
Reuse
- Records the events
- Called when the game service is ready .
- Resolve a connection failure
- Build the request for the GIS service .
- Authorizes the Google Analytics application .
- Loads player information from game server .
- Creates a GjScoreboardEntry from a JSON value .
- Downloads the contents of a URL .
- Build query stat request .
- Get an array of ListenerBoardBoardEntry objects .
gdx-gamesvcs Key Features
gdx-gamesvcs Examples and Code Snippets
Trending Discussions on gdx-gamesvcs
Trending Discussions on gdx-gamesvcs
QUESTION
I want to implement Google Play Games Services in my game on the libgdx engine. I tried using gdx-gamesvcs for this. But I am having trouble saving data. I understood from the example that one value is being saved, not the entire state of the game. So I decided to check it out: save and load one value using gsClient.loadGameState
and gsClient.saveGameState
. I deliberately deleted the game data from the device. But as a result, not only the test value changed, but many others as well. I thought that the state of the entire game is being saved, but the values obtained do not fit into the logic of the game and could not be obtained in it. How should I use this tool and is it worth it at all, or is it better to use what libgdx itself offers? Here is a piece of code:
if (gsClient.isSessionActive()) {
try {
gsClient.saveGameState("data", intToByteArray(testValue), 0, null);
} catch (UnsupportedOperationException unsupportedOperationException) {
}
if (gsClient.isSessionActive()) {
try {
gsClient.loadGameState("data", new ILoadGameStateResponseListener() {
@Override
public void gsGameStateLoaded(byte[] gameState) {
if (gameState != null) {
setTestValue(bytesToInt(gameState));
}
}
});
} catch (UnsupportedOperationException unsupportedOperationException) {
}
}
UPD Yes, saving occurs both to the cloud and to the device, for saving to the device I use Preferences. I have a Google account login button in the game, it works, I have repeatedly seen this standard bar of my account level, which appears at the top when I log in. Everything is set up in the developer console too, I have an id for achievements and leaderboards. In code, I work with the client like this (In the create()
method):
public IGameServiceClient gsClient;
if (gsClient == null) {
gsClient = new MockGameServiceClient(1) {
@Override
protected Array getLeaderboardEntries() {
return null;
}
@Override
protected Array getGameStates() {
return null;
}
@Override
protected byte[] getGameState() {
return new byte[0];
}
@Override
protected Array getAchievements() {
return null;
}
@Override
protected String getPlayerName() {
return null;
}
};
}
gsClient.setListener(this);
gsClient.resumeSession();
Next is loading.
The exception is not caught, I removed it and everything works as before.
ANSWER
Answered 2020-Aug-20 at 19:56Well, libgdx offers no built-in cloud-save, it is hard to use it for that. :-)
You should in any case save to local AND to cloud, as the cloud is not very fast to load its state.
I can see no problem in your code besides the fact that you swallow an UnsupportedOperationException
that is thrown if you did not activate cloud save feature. So the interesting question is: what happens if you don't swallow the exception, and did you intialize GpgsClient
with cloud save enabled? Are you really logged in to Gpgs, and is the feature also activated in your developer console?
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install gdx-gamesvcs
Support
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesExplore Kits - Develop, implement, customize Projects, Custom Functions and Applications with kandi kits
Save this library and start creating your kit
Share this Page