Game loading and gameplay markup

Game loading

Yandex Games operates worldwide, so collecting statistics is important for improving game loading speed and availability. For example, we use this data to decide where to deploy new data centers.

Understanding when games are loaded will allow us to add new features: showing a loading screen common to all games, game screenshots, or reviews. This will make games more attractive.

ysdk.features.LoadingAPI.ready()

The method should be called when the game has loaded all resources and is ready to interact with the user.

Make sure that at the moment of calling the method from Game Ready in the game:

  • all elements are ready to interact with the player;
  • there are no loading screens.

You can track the Game Ready metric in the Performance tab in DevTools.

Example

1const ysdk = await YaGames.init();
2
3// Informing the platform that the game has loaded and is ready to play.
4ysdk.features.LoadingAPI?.ready();
1YaGames.init()
2    .then((ysdk) => {
3        // Informing the platform that the game has loaded and can start playing.
4        ysdk.features.LoadingAPI?.ready();
5    })
6    .catch(console.error);

Gameplay

It is important for us to track when and how users interact with games. For this purpose, the SDK has special methods that allow marking the start and stop of gameplay. Using them will help us improve the accuracy of recommendations in the catalog, distribute games on more platforms, and form additional metrics in the developer console.

ysdk.features.GameplayAPI.start()

This method should be called when the player starts or resumes the gameplay. Such cases include:

  • Starting a level.
  • Closing the menu.
  • Unpausing.
  • Resuming the game after displaying ads.
  • Returning to the current browser tab.

Make sure that after sending the GameplayAPI.start() event, the gameplay is immediately started.

ysdk.features.GameplayAPI.stop()

This method should be called when the player pauses or ends the gameplay. Such cases include:

  • Completing a level or losing.
  • Opening the menu.
  • Pausing the game.
  • Displaying fullscreen or rewarded ads.
  • Switching to another browser tab.

Ensure that after sending the GameplayAPI.stop() event, the gameplay is stopped.

Warning

At the moment of resuming gameplay, call the method ysdk.features.GameplayAPI.start() again.

Example

 1const ysdk = await YaGames.init();
 2
 3// Informing about starting the gameplay.
 4ysdk.features.GameplayAPI?.start();
 5
 6// Gameplay is active.
 7
 8// Informing about stopping the gameplay:
 9// player has entered menu, completed the level, or an ad is planned to be shown.
10ysdk.features.GameplayAPI?.stop();
 1YaGames.init()
 2    .then((ysdk) => {
 3        // Informing about starting the gameplay.
 4        ysdk.features.GameplayAPI?.start();
 5
 6        // Gameplay is active.
 7
 8        // Informing about stopping the gameplay:
 9        // player has entered menu, completed the level, or an ad is planned to be shown.
10        ysdk.features.GameplayAPI?.stop();
11    });

Note

Support staff help you publish a ready-made game on the Yandex Games platform. For applied questions about development and testing, other developers will answer in the Discord community.

If you encounter a problem or have a question while using the Yandex Games SDK, contact support:

Write to chat