Ich machte ein kleines Spiel mit cocos2d-x für Android. Ich habe derzeit Schwierigkeiten, Cloud Save für mein Spiel zu implementieren. Das einzige verbleibende Problem ist, dass es nicht festgeschrieben wird.Wie CommitBlocking commit? - Google Play Game Services
Die GPGS-API, die ich verwende, ist C++. Scrollen Sie einfach runter zum Commit-Blocking dort.
//using sample codes from Google.
game_services->Snapshots().Open
(
"some_save_file",
gpg::SnapshotConflictPolicy::MANUAL,
[this, &save](gpg::SnapshotManager::OpenResponse const& response)
{
LOGI("Saving snapshot");
if(gpg::IsSuccess(response.status))
{
LOGI("Open success");
gpg::SnapshotMetadata metadata = response.data;
if (response.conflict_id != "")
{
//Conflict detected
//Settle conflict
}
LOGI("Getting PNG data");
//get cover image data
//some code to get png data in to png_vector
LOGI("Building snapshot builder");
//setting up the builder
gpg::SnapshotMetadataChange::Builder builder;
gpg::SnapshotMetadataChange metadata_change =
builder
.SetDescription("Recall Save File")
.SetCoverImageFromPngData(png_vector)
.Create();
LOGI("Commiting");
// Save the snapshot.
// This is the part that does not work !!!!!
gpg::SnapshotManager::CommitResponse commitResponse =
game_services->Snapshots().CommitBlocking(gpg::Timeout(3000), response.data, metadata_change, save);
if (IsSuccess(commitResponse.status))
CSH_LOGI("Saved game");
else
CSH_LOGI("Saved game failed error: %d", commitResponse.status);
}
);
Wenn kompiliert und läuft am Telefon:
06-25 16:51:47.405: V/GamesNativeSDK(10717): Snapshot was not committed, discarding.
06-25 16:51:47.410: V/GamesNativeSDK(10717): Snapshot discard complete.
Ich hatte versucht, mit Commit(), die Absturz das Spiel, und CommitBlocking() ohne Timeout, es nicht begeht.
Ich verbrachte fast eine Woche zu diesem Problem mit der Dokumentation und Proben. Also, hat jemand dieses Problem schon einmal getroffen? Wenn ja, teile mit mir wie man es löst.
Danke.
Haben Sie zuerst die Snapshots mithilfe von [EnableSnapshots()] (https://developers.google.com/games/services/cpp/savedgames#enabling_the_savedgames_service) aktiviert? Überprüfen Sie die vollständige [C++ speichern Implementierung] (https://github.com/playgameservices/cpp-android-basic-samples/blob/master/samples-android/CollectAllTheStarsNativeActivity.cpp) Beispiel in Github. Es wird dir sehr helfen. – noogui
Ja, habe ich getan. Ich habe ein paar Fehler gefunden und sie gelöst. Danke: D –