2017-02-02 5 views
0

Google Play Games C++では、私にとって正しい友人データが返されていないようです。Google Play Games C++ API - プログラムで友だちにアクセスできない

ここでの基本的な考えは、友だちのスコアのリストを表示するページがゲーム内にあることです。さらに、ゲームをプレイしているときは、あなたが近づいているときと、あなたの友人のベストスコアに合格したときに、インジケータが画面上に表示されます。

ゲームはCocos2d-xで書かれています。その結果、Google PlayゲームC++ライブラリが使用されています。 GPGが正常に認証され、その他の機能(実績のロックを解除して実際にスコアを送信するなど)が正しく機能しています。 Googleの誰かが読んでいる場合は、バージョン2.2のリリースノートがウェブサイトにありますが、ダウンロードページには2.1しかないので、これは私たちが使っているものです。

いずれにしても、お友達であるGoogle Playアカウントが異なる2つの端末があります。私たちは、デフォルトのネイティブゲームサービスリーダーボードUIを開くオプションを持っています。ソーシャルリーダーボードに行くと、両方のデバイスがこのページの他のプレイヤーのスコアが高くなるので、2つのアカウントを友人にしたようです。

残念ながら、C++ APIを使用してプログラムでこの友人データを取得できません。

ここに関連コードがあります。

void GameCenterSession::fetchFriends() 
{ 
    __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Fetching friends!"); 

    //GET INVITABLE FRIENDS 
    game_services_->Players().FetchInvitable(gpg::DataSource::CACHE_OR_NETWORK, [] (gpg::PlayerManager::FetchListResponse response) { 
     __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Got invitable friends response: %d", response.status); 
     __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Got invitable players info! Num players: %d", response.data.size()); 
     if (gpg::IsSuccess(response.status)) { 
      //PROCESS PLAYERS 
      GameCenterSession::getInstance()->onPlayersInfoReceived(kRequestFriendsInfo, response.data); 
     } 
    }); 

    //GET CONNECTED FRIENDS 
    game_services_->Players().FetchConnected(gpg::DataSource::CACHE_OR_NETWORK, [] (gpg::PlayerManager::FetchListResponse response) { 
     __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Got connected friends response: %d", response.status); 
     __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Got connected players info! Num players: %d", response.data.size()); 
    }); 
} 

void GameCenterSession::onPlayersInfoReceived(const int requestId, std::vector<gpg::Player> playersInfo) { 

    __android_log_print(ANDROID_LOG_INFO, "MyGame!", "onPlayersInfoReceived num players: %d", playersInfo.size()); 
    const gpg::ScorePage::ScorePageToken distanceToken = game_services_->Leaderboards().ScorePageToken(
     kLeaderboardBestDistance, 
     gpg::LeaderboardStart::TOP_SCORES, 
     gpg::LeaderboardTimeSpan::ALL_TIME, 
     gpg::LeaderboardCollection::SOCIAL 
    ); 

    //FETCH ALL TIME SOCIAL SCORES FOR DISTANCE 
    game_services_->Leaderboards().FetchScorePage(gpg::DataSource::CACHE_OR_NETWORK, distanceToken, 1000, [] (gpg::LeaderboardManager::FetchScorePageResponse response) { 

     if (gpg::IsSuccess(response.status) && response.data.Valid()) { 
      __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Got social leaderboard! Num players: %d", response.data.Entries().size()); 
      gpg::ScorePage::Entry myEntry = gpg::ScorePage::Entry(); 

      //search through and find my score! 
      for (auto score : response.data.Entries()) { 
       __android_log_print(ANDROID_LOG_INFO, "MyGame!", "%s got distance %d", score.PlayerId().c_str(), score.Score().Value()); 


       if (score.PlayerId().compare(GameCenterSession::getInstance()->myPlayer.Id()) == 0) { 
        __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Distance - Yup that's me"); 
        myEntry = score; 
       } else { 
        __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Distance - It's another player!"); 
       } 
      } 

      GameCenterSession::getInstance()->onScoresReceived(kRequestFriendsDistancesInfo, myEntry, response.data.Entries()); 
     } 
    }); 


    const gpg::ScorePage::ScorePageToken scoreToken = game_services_->Leaderboards().ScorePageToken(
     kLeaderboardBestScore, 
     gpg::LeaderboardStart::TOP_SCORES, 
     gpg::LeaderboardTimeSpan::ALL_TIME, 
     gpg::LeaderboardCollection::SOCIAL 
    ); 

    game_services_->Leaderboards().FetchScorePage(gpg::DataSource::CACHE_OR_NETWORK, scoreToken, 1000, [] (gpg::LeaderboardManager::FetchScorePageResponse response) { 
     if (gpg::IsSuccess(response.status) && response.data.Valid()) { 

      gpg::ScorePage::Entry myEntry = gpg::ScorePage::Entry(); 

      //search through and find my score! 
      for (auto score : response.data.Entries()) { 
       __android_log_print(ANDROID_LOG_INFO, "MyGame!", "%s got score %d", score.PlayerId().c_str(), score.Score().Value()); 


       if (score.PlayerId().compare(GameCenterSession::getInstance()->myPlayer.Id()) == 0) { 
        __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Score - Yup that's me"); 
        myEntry = score; 
       } else { 
        __android_log_print(ANDROID_LOG_INFO, "MyGame!", "Score - It's another player!"); 
       } 
      } 

      GameCenterSession::getInstance()->onScoresReceived(kRequestFriendsScoresInfo, myEntry, response.data.Entries()); 
     } 
    }); 

    if (requestId == kRequestFriendsInfo) 
    { 
     friends = playersInfo; 
    } 
} 

コードを見ると、最初に友だちリストを取得し、そのリストに含まれているプレイヤーの数を確認します。私は招待可能な友達(私が欲しいと思う文書で判断してください)と接続された友達(テストのように)との両方にアクセスしようとします。私は距離とスコアのすべての時間社会的なリーダーボードを2つの異なるリーダーをつかむために行きます、そして、結果にいくつのプレーヤーがいるかを確認します。ここに私のログ出力があります。あなたが見ることができるように

//デバイス1

I/MyGame!(1510): Google Play Games authenticated successfully! 
I/MyGame!(1510): Fetching friends! 
I/MyGame!(1510): Got invitable friends response: 1 
I/MyGame!(1510): Got invitable players info! Num players: 0 
I/MyGame!(1510): onPlayersInfoReceived num players: 0 
I/MyGame!(1510): Got connected friends response: 1 
I/MyGame!(1510): Got connected players info! Num players: 0 
I/MyGame!(1510): Got social leaderboard! Num players: 1 
I/MyGame!(1510): g1703186947466536XXXX got distance 310 
I/MyGame!(1510): Distance - Yup that's me 
I/MyGame!(1510): g1703186947466536XXXX got score 2510 
I/MyGame!(1510): Score - Yup that's me 

//デバイス2

01-23 17:11:27.227 17187 17234 I MyGame!: Google Play Games authenticated successfully! 
01-23 17:11:27.250 17187 17234 I MyGame!: Fetching friends! 
01-23 17:11:27.451 17187 17234 I MyGame!: Got invitable friends response: 1 
01-23 17:11:27.451 17187 17234 I MyGame!: Got invitable players info! Num players: 0 
01-23 17:11:27.451 17187 17234 I MyGame!: onPlayersInfoReceived num players: 0 
01-23 17:11:27.581 17187 17234 I MyGame!: Got connected friends response: 1 
01-23 17:11:27.581 17187 17234 I MyGame!: Got connected players info! Num players: 0 
01-23 17:11:27.973 17187 17234 I MyGame!: Got social leaderboard! Num players: 1 
01-23 17:11:27.973 17187 17234 I MyGame!: g0152008166550356XXXX got distance 712 
01-23 17:11:27.973 17187 17234 I MyGame!: Distance - Yup that's me 
01-23 17:11:28.444 17187 17234 I MyGame!: g0152008166550356XXXX got score 2142 
01-23 17:11:28.444 17187 17234 I MyGame!: Score - Yup that's me 

、私のコールバック全てが成功した結果コードを返します。残念ながら、いずれのデバイスも友人を返しません。ソーシャルリーダーボードのコールバックには、友人のスコアではなく、デバイス上のプレーヤーのみが含まれます。

私は可能な限りドキュメントを守りましたが、問題を見つけることができずにコードを見直しましたが、それは単なるセマンティクスの問題だと私の間違いを聞いてうれしいです。私はここで何か間違っているのですか、それともC++ API自体に問題がありますか?

ありがとうございます。

答えて

0

APIが期待どおりに動作しています。送信元:https://android-developers.googleblog.com/2016/12/games-authentication-adopting-google.html

Google+はもう統合されていません Announced last year、この移行中にゲームがGoogle+から切り離されました。その結果、サークルを介して接続されたプレーヤーを獲得するためのパブリックAPIは機能しなくなりましたが、マルチプレイヤー招待状やソーシャルリーダーボードの標準UIは引き続き機能しました。 2017年2月からは、Google+データにアクセスできないため、標準UIにソーシャルグラフの結果は表示されません。これは、Android上のマルチプレイヤーゲーム、ソーシャルリーダーボード、ギフトAPIに影響します。これらのAPIは正常に返されますが、プレーヤーの空のリストが返されます。

+0

お返事ありがとうございます。私はあなたがこのブログ記事の作家であることを知っていますので、この機能がもはや機能しないことを伝えるメモを関連文書に追加することを親切に要求します。これを実装してデバッグするのに多くの時間を費やしましたが、リンクされたブログ記事を見る前にこれらの機能が機能しなくなったという言葉はありませんでした。再度、感謝します。 – noodleben

関連する問題