gpgs.* — Google Play 游戏服务

类型
修订 版本 2024.3703
关键词 Google Play 游戏服务, 游戏网络, gpgs
平台 Android

概述

Google Play 游戏服务 插件支持访问Google Play 游戏服务用于游戏联网,包括成就、排行榜、多人游戏、任务、视频等。

本文档概述了传统的 Google Play 游戏服务插件,主要用于仍在使用多人游戏功能的 Android 游戏。 对于新的 Android 游戏,您应该使用 Google Play 游戏服务 v2 插件。

重要
  • 要使用此插件,您必须按照此处所述实施 Google 应用许可,并使用此处所述的私钥对 .apk 进行签名。

  • 以前,此插件也与 iOS 兼容,但 Google 不再支持与 iOS 集成。 如果您以前在 iOS 上实现了此服务,则应将该实现迁移到其他服务。

如果您遇到Google Play 游戏服务实施此插件后出现登录问题/错误,请确保您已在 Google Play 开发者控制台 中启用了**云端硬盘 API** 和Google Play Developer API

语法

local gpgs = require( "plugin.gpgs" )

函数

这些核心函数管理与 Google 服务器的连接、身份验证和其他任务。

gpgs.init()

gpgs.isConnected()

gpgs.login()

gpgs.logout()

gpgs.getAppId()

gpgs.getAccountName()

gpgs.getServerAuthCode()

gpgs.getSdkVersion()

gpgs.setPopupPosition()

gpgs.loadGame()

gpgs.loadImage()

gpgs.showSettings()

gpgs.enableDebug()

节点

此插件的特定功能方面被划分为节点,以便更好地组织

gpgs.achievements

gpgs.leaderboards

gpgs.players

gpgs.events

gpgs.quests

gpgs.requests

gpgs.snapshots

gpgs.videos

事件

init

login

loadGame

loadImage

showSettings

getAccountName

getServerAuthCode

类型

游戏

图像

项目设置

要使用此插件,请在 build.settingsplugins 表中添加一个条目。 添加后,构建服务器将在构建阶段集成该插件。

settings = {

    plugins =
    {
        ["plugin.gpgs"] =
        {
            publisherId = "com.coronalabs",
            supportedPlatforms = { android=true }
        },
    },
}

此外,您必须指定Google Play 游戏应用 IDbuild.settingsandroid 表中,作为 googlePlayGamesAppId

settings = {

    android =
    {
        googlePlayGamesAppId = "YOUR_APPLICATION_ID",
    },
}