AI-generated Key Takeaways
-
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 checkisEnabled()
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
returnsfalse
. When the value changes tofalse
you must stop playing any sound immediately. When the value changes totrue
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 checkisEnabled
in every game loop. - If you do use
subscribe
you must also useisEnabled
to get the initial value.
- You can either use
Examples
engine.sound.setMute(!GameSnacks.audio.isEnabled);
GameSnacks.audio.subscribe((isEnabled) => engine.sound.setMute(!isEnabled));