Game Loading and Gameplay Markup

Game Loading

Yandex Games operate worldwide, hence gathering statistics is crucial for improving loading speeds and the accessibility of games. For instance, these data help us decide where to deploy new data centers.

Understanding when games are loaded will allow us to add new features such as showing a common loading screen for all games, game screenshots, or reviews. This will increase the attractiveness of games.

ysdk.features.LoadingAPI.ready()

The method ysdk.features.LoadingAPI.ready() 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 the call in the game:

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

Example

const ysdk = await YaGames.init();

// Informing the platform that the game has loaded and is ready to play.
ysdk.features.LoadingAPI?.ready()
YaGames.init()
    .then((ysdk) => {
        // Informing the platform that the game has loaded and can start playing.
        ysdk.features.LoadingAPI?.ready()
    })
    .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()

The method ysdk.features.GameplayAPI.start() needs to be called when a player starts or resumes gameplay:

  • starting a level;
  • closing a menu;
  • resuming from a pause;
  • resuming the game after showing ads;
  • returning to the current browser tab.

Ensure after sending the GameplayAPI.start() event that the gameplay is immediately started.

ysdk.features.GameplayAPI.stop()

The method ysdk.features.GameplayAPI.stop() should be called when a player pauses or ends gameplay:

  • completing or failing a level;
  • calling up a menu;
  • pausing the game;
  • showing full-screen 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

const ysdk = await YaGames.init();

// Informing about starting the gameplay.
ysdk.features.GameplayAPI?.start()

// Gameplay is active.
            
// Informing about stopping the gameplay:
// player has entered menu, completed the level, or an ad is planned to be shown.
ysdk.features.GameplayAPI?.stop()
YaGames.init()
    .then((ysdk) => {
        // Informing about starting the gameplay.
        ysdk.features.GameplayAPI?.start()
        
        // Gameplay is active.
        
        // Informing about stopping the gameplay:
        // player has entered menu, completed the level, or an ad is planned to be shown.
        ysdk.features.GameplayAPI?.stop()
    });

Note

Our support team can help publish finished games or WebApps on Yandex Games. If you have any questions about development or testing, ask them in the Discord channel.

If you are facing an issue or have a question regarding the use of Yandex Games SDK, please contact support:

Write to chat