Audio isEnabled method
Stay organized with collections
Save and categorize content based on your preferences.
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));
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-09-03 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-09-03 UTC."],[[["`isEnabled()` determines whether game sound should be currently audible."],["Games must immediately stop or resume sound based on the boolean value returned by `isEnabled()`."],["Developers can utilize either the `subscribe` method for updates or check `isEnabled()` in each game loop to ensure sound behavior aligns with its value."]]],[]]