谷歌实时多人游戏玩家的名字



在创建房间和自动匹配时一切都很好,但问题是当我调用p.t getdisplayname()时,在此代码中它不返回对手的名称,它返回一些垃圾字母。

      void updatePeerScoresDisplay() {
    ((TextView) findViewById(R.id.score0)).setText(formatScore(mScore) + " - Me");
    int[] arr = {
            R.id.score1, R.id.score2, R.id.score3
    };
    int i = 0;
    if (mRoomId != null) {
        for (Participant p : mParticipants) {
            String pid = p.getParticipantId();
            if (pid.equals(mMyId))
                continue;
            if (p.getStatus() != Participant.STATUS_JOINED)
                continue;

           int score = mParticipantScore.containsKey(pid) ? mParticipantScore.get(pid) : 0;
            ((TextView) findViewById(arr[i])).setText(formatScore(score) + " - "+
                    p.getDisplayName());
            ++i;
        }
    }

它返回类似Player234的东西,它不会返回玩家的名字,即使他/她在你的圈子里(正如我所经历的)。这就是随机对手匹配的意义。

google play game实时多人游戏如何获得快速匹配玩家的名字?

最新更新