其他游戏链接

Yandex Games的SDK允许您自动获得指向您其他游戏的正确链接(包括特定游戏和游戏列表),以便在游戏中引用它们。

为确保游戏确实可在当前平台和域上访问(参见需求条款8.4.1),请使用GamesAPI.getAllGames()GamesAPI.getGameByID()方法。

ysdk.features.GamesAPI.getAllGames()

当您需要获取有关当前平台和域名上可用的所有游戏的信息时,使用方法 ysdk.features.GamesAPI.getAllGames()

示例

1ysdk.features.GamesAPI.getAllGames().then(({games, developerURL}) => {
2    games.forEach((game) => {
3        // 游戏处理逻辑。
4    })
5}).catch(err => {
6    // 获取游戏数据时出错。
7})

回应格式

1{
2    games: IGame[];
3    developerURL: string;
4}

参数

类型

描述

games

IGame[]

包含游戏信息的对象数组。

developerURL

string

开发者页面的链接。

ysdk.features.GamesAPI.getGameByID()

当您需要获取有关特定游戏及其在当前平台和域上的可用性的数据时,使用方法 ysdk.features.GamesAPI.getGameByID(appID)

  • appID —— 开发者控制台中的游戏 ID。

示例

1ysdk.features.GamesAPI.getGameByID(100000).then(({isAvailable, game}) => {
2    if (isAvailable) {
3        // 如果游戏可用,请处理 game。
4    } else {
5        // 如果游戏无法玩,即 game 对象未定义的逻辑 (undefined).
6    }
7}).catch(err => {
8    // 获取游戏数据时出错。
9})

回应格式

1{
2    game?: IGame;
3    isAvailable: boolean;
4}

参数

类型

描述

game

IGame

关于游戏的信息对象。

isAvailable

boolean

表示游戏是否可用:

  • true —— 游戏可用;
  • false —— 游戏不可用,game 对象未定义(undefined)。

IGame 接口

1interface IGame {
2    appID: string;
3    title: string;
4    url: string;
5    coverURL: string;
6    iconURL: string;
7}

参数

类型

描述

appID

string

开发者控制台中设置的游戏标识符。

title

string

游戏的名称。

url

string

游戏的链接。

coverURL

string

游戏封面的链接。

iconURL

string

游戏图标的链接。


备注

技术支持团队将协助您将已完成的游戏发布到 Yandex 游戏平台。关于开发和测试方面的具体问题,其他开发人员将在Discord 频道中进行回答。

如果您遇到 Yandex Games SDK 方面的问题或有其他问题想要咨询,请联系支持部门:

写入聊天信息

包含游戏信息的对象数组。

开发者页面的链接。

关于游戏的信息对象。

表示游戏是否可用:

  • true —— 游戏可用;
  • false —— 游戏不可用,game 对象未定义(undefined)。

开发者控制台中设置的游戏标识符。

游戏的名称。

游戏的链接。

游戏封面的链接。

游戏图标的链接。