Skip to content

Commit d98b984

Browse files
committed
SoundManager.volume now has its input value clamped to ensure it's between 0 and 1 (inclusive)
1 parent 36c7084 commit d98b984

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

src/sound/SoundManager.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,7 @@ Object.defineProperty(Phaser.SoundManager.prototype, "mute", {
765765

766766
/**
767767
* @name Phaser.SoundManager#volume
768-
* @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1.
768+
* @property {number} volume - Gets or sets the global volume of the SoundManager, a value between 0 and 1. The value given is clamped to the range 0 to 1.
769769
*/
770770
Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
771771

@@ -777,6 +777,15 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
777777

778778
set: function (value) {
779779

780+
if (value < 0)
781+
{
782+
value = 0;
783+
}
784+
else if (value > 1)
785+
{
786+
value = 1;
787+
}
788+
780789
if (this._volume !== value)
781790
{
782791
this._volume = value;

0 commit comments

Comments
 (0)