Audio isEnabled method

  • isEnabled() is a method that indicates whether game sound should currently be playing.

  • Games must immediately react to changes in isEnabled() by stopping or resuming audio playback accordingly.

  • Developers can use either subscribe for real-time updates or check isEnabled() within the game loop to monitor sound status.

  • Initial sound state should be determined using isEnabled() even when using subscriptions.

isEnabled(): boolean

Determines if game sound should be audible at this instant.

Requirements

  • Your game must not omit sound while isEnabled returns false. When the value changes to false you must stop playing any sound immediately. When the value changes to true you must immediately resume any sound that would have been playing.
    • You can either use subscribe to be notified when this value changes, or you can check isEnabled in every game loop.
    • If you do use subscribe you must also use isEnabled to get the initial value.

Examples

engine.sound.setMute(!GameSnacks.audio.isEnabled);
GameSnacks.audio.subscribe((isEnabled) => engine.sound.setMute(!isEnabled));