Skip to main content

Sounds

Overview

A unified mechanism for managing the sound state in a game. No need to resolve sound state conflicts in the game. One point of control. The state is preserved even on reload. Monitor stopping and resuming sounds and music in the game.

The SDK notifies when to turn sounds or music or overall sound on or off during:

  • Game pause (manual pause, minimizing window, switching tabs, etc.);
  • Ad display (interstitial, rewarded);
  • Player's explicit choice to mute/unmute sound via buttons on the platform outside the game;
  • Manual sound toggling directly in the SDK.

Events

FREE

Events trigger automatically when there's a need to change the sound state.

// Sound muted
gp.sounds.on('mute', () => {
// Need to mute all sounds in the game
});
// Sound effects muted
gp.sounds.on('mute:sfx', () => {
// Need to mute sound effects (button clicks, gunfire noise, walking sounds, jumping, etc.)
});
// Music muted
gp.sounds.on('mute:music', () => {
// Need to mute music in the game
});

// Sound unmuted
gp.sounds.on('unmute', () => {
// Need to unmute all sounds in the game
});
// Sound effects unmuted
gp.sounds.on('unmute:sfx', () => {
// Need to unmute sound effects in the game
});
// Music unmuted
gp.sounds.on('unmute:music', () => {
// Need to unmute music in the game
});

State

You can find out the current sound state in the game.

// All sounds are muted
gp.sounds.isMuted;
// Sound effects are muted
gp.sounds.isSFXMuted;
// Music is muted
gp.sounds.isMusicMuted;

Actions

You can mute or unmute sound or music through our SDK, we remember the choice and sync it with the state on the platform so that you don't have to manually resolve sound state conflicts.

// Mute all sounds
gp.sounds.mute();
// Unmute all sounds
gp.sounds.unmute();

// Mute sound effects
gp.sounds.muteSFX();
// Unmute sound effects
gp.sounds.unmuteSFX();

// Mute music
gp.sounds.muteMusic();
// Unmute music
gp.sounds.unmuteMusic();

Stay in Touch

Other documents of this chapter available Here. To get started, welcome to the Tutorials chapter.

GamePush Community Telegram: @gs_community.

For your suggestions e-mail: [email protected]

We Wish you Success!