Audio isEnabled method

  • isEnabled() checks if game sound should be audible at this moment.

  • When isEnabled() returns false, game sound must stop immediately, and when it returns true, sound should resume.

  • You can monitor isEnabled() by using subscribe or checking in every game loop, but if using subscribe, also use isEnabled() for the initial value.

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));