I was doing a little game using cocos2d-x for android. I am currently struggling to implement Cloud Save for my game. The only problem left is that it does not commit.
The GPGS API I am using is C++. Just scroll down to the commitblocking there.
//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);
}
);
When compiled and running on phone :
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.
I had tried with Commit(), which crash the game, and CommitBlocking() with no timeout, it doesn't commit too.
I spent almost a week on this problem looking at the documentation and samples. So, anyone met this problem before ? If do, do share with me how to solve it.
Thanks.
Aucun commentaire:
Enregistrer un commentaire