Fixed issue stopping SoundManager.volume from working correctly on a global volume basis (fix # 488)

This commit is contained in:
photonstorm
2014-02-26 14:40:55 +00:00
parent 4a97861ff8
commit d0fa50f014
3 changed files with 73 additions and 7 deletions
+1
View File
@@ -168,6 +168,7 @@ Bug Fixes:
* Fixed TilemapParser - would spit out a tileset warning if margin/spacing were set (fix #485, thanks Cybolic)
* AnimationParser.spriteSheet wasn't taking the margin or spacing into account when calculating the numbers of sprites per row/column, nor was it allowing for extra power-of-two padding at the end (fix #482, thanks yig)
* AnimationManager.add documentation said that 'frames' could be null, but the code couldn't handle this so it defaults to an empty array if none given (thanks yig)
* Fixed issue stopping SoundManager.volume from working correctly on a global volume basis (fix # 488)
TO DO:
+53
View File
@@ -0,0 +1,53 @@
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });
function preload() {
game.load.image('disk', 'assets/sprites/ra_dont_crack_under_pressure.png');
// Firefox doesn't support mp3 files, so use ogg
game.load.audio('boden', ['assets/audio/bodenstaendig_2000_in_rock_4bit.mp3', 'assets/audio/bodenstaendig_2000_in_rock_4bit.ogg']);
}
var s;
var music;
function create() {
game.stage.backgroundColor = '#182d3b';
game.input.touch.preventDefault = false;
music = game.add.audio('boden');
music.play();
s = game.add.sprite(game.world.centerX, game.world.centerY, 'disk');
s.anchor.setTo(0.5, 0.5);
game.input.onDown.add(changeVolume, this);
}
function changeVolume(pointer) {
if (pointer.y < 300)
{
game.sound.volume += 0.1;
// music.volume += 0.1;
}
else
{
game.sound.volume -= 0.1;
// music.volume -= 0.1;
}
}
function update() {
s.rotation += 0.01;
}
function render() {
game.debug.renderSoundInfo(music, 20, 32);
}
+19 -7
View File
@@ -371,6 +371,12 @@ Phaser.SoundManager.prototype = {
},
/**
* Internal mute handler called automatically by the Sound.mute setter.
*
* @method Phaser.SoundManager#setMute
* @private
*/
setMute: function () {
if (this._muted)
@@ -397,6 +403,12 @@ Phaser.SoundManager.prototype = {
},
/**
* Internal mute handler called automatically by the Sound.mute setter.
*
* @method Phaser.SoundManager#unsetMute
* @private
*/
unsetMute: function () {
if (!this._muted || this._codeMuted)
@@ -487,21 +499,21 @@ Object.defineProperty(Phaser.SoundManager.prototype, "volume", {
set: function (value) {
value = this.game.math.clamp(value, 1, 0);
this._volume = value;
if (this.usingWebAudio)
{
this.masterGain.gain.value = value;
}
// Loop through the sound cache and change the volume of all html audio tags
for (var i = 0; i < this._sounds.length; i++)
else
{
if (this._sounds[i].usingAudioTag)
// Loop through the sound cache and change the volume of all html audio tags
for (var i = 0; i < this._sounds.length; i++)
{
this._sounds[i].volume = this._sounds[i].volume * value;
if (this._sounds[i].usingAudioTag)
{
this._sounds[i].volume = this._sounds[i].volume * value;
}
}
}