AI-generated Key Takeaways
-
isEnabled()checks if game sound should be audible at this moment. -
When
isEnabled()returnsfalse, game sound must stop immediately, and when it returnstrue, sound should resume. -
You can monitor
isEnabled()by usingsubscribeor checking in every game loop, but if usingsubscribe, also useisEnabled()for the initial value.
isEnabled(): boolean
Determines if game sound should be audible at this instant.
Requirements
- Your game must not omit sound while
isEnabledreturnsfalse. When the value changes tofalseyou must stop playing any sound immediately. When the value changes totrueyou must immediately resume any sound that would have been playing.- You can either use
subscribeto be notified when this value changes, or you can checkisEnabledin every game loop. - If you do use
subscribeyou must also useisEnabledto get the initial value.
- You can either use
Examples
engine.sound.setMute(!GameSnacks.audio.isEnabled);
GameSnacks.audio.subscribe((isEnabled) => engine.sound.setMute(!isEnabled));