mirror of
https://github.com/doublespeakgames/adarkroom.git
synced 2026-06-25 05:42:30 +08:00
add button to turn volume on and off
This commit is contained in:
@@ -176,6 +176,26 @@ var AudioEngine = {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
mute: function () {
|
||||||
|
AudioEngine.master.gain.linearRampToValueAtTime(
|
||||||
|
0.0,
|
||||||
|
AudioEngine.audioContext.currentTime + AudioEngine.FADE_TIME
|
||||||
|
);
|
||||||
|
},
|
||||||
|
setVolume: function (volume) {
|
||||||
|
if (!AudioEngine.master) return; // master may not be ready yet
|
||||||
|
if (!volume) {
|
||||||
|
volume = 1.0;
|
||||||
|
}
|
||||||
|
AudioEngine.master.gain.setValueAtTime(
|
||||||
|
AudioEngine.master.gain.value,
|
||||||
|
AudioEngine.audioContext.currentTime
|
||||||
|
);
|
||||||
|
AudioEngine.master.gain.linearRampToValueAtTime(
|
||||||
|
volume,
|
||||||
|
AudioEngine.audioContext.currentTime + AudioEngine.FADE_TIME / 2
|
||||||
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -133,6 +133,12 @@
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$('<span>')
|
||||||
|
.addClass('volume menuBtn')
|
||||||
|
.text(_('sound off.'))
|
||||||
|
.click(Engine.toggleVolume)
|
||||||
|
.appendTo(menu);
|
||||||
|
|
||||||
$('<span>')
|
$('<span>')
|
||||||
.addClass('appStore menuBtn')
|
.addClass('appStore menuBtn')
|
||||||
.text(_('get the app.'))
|
.text(_('get the app.'))
|
||||||
@@ -215,6 +221,10 @@
|
|||||||
Ship.init();
|
Ship.init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!$SM.get('config.soundOn')){
|
||||||
|
Engine.toggleVolume();
|
||||||
|
}
|
||||||
|
|
||||||
if($SM.get('config.lightsOff', true)){
|
if($SM.get('config.lightsOff', true)){
|
||||||
Engine.turnLightsOff();
|
Engine.turnLightsOff();
|
||||||
}
|
}
|
||||||
@@ -782,6 +792,18 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
toggleVolume: function() {
|
||||||
|
if ($SM.get('config.soundOn')) {
|
||||||
|
$('.volume').text(_('sound on.'));
|
||||||
|
$SM.set('config.soundOn', false);
|
||||||
|
AudioEngine.mute();
|
||||||
|
} else {
|
||||||
|
$('.volume').text(_('sound off.'));
|
||||||
|
$SM.set('config.soundOn', true);
|
||||||
|
AudioEngine.setVolume(1.0);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
setInterval: function(callback, interval, skipDouble){
|
setInterval: function(callback, interval, skipDouble){
|
||||||
if( Engine.options.doubleTime && !skipDouble ){
|
if( Engine.options.doubleTime && !skipDouble ){
|
||||||
Engine.log('Double time, cutting interval in half');
|
Engine.log('Double time, cutting interval in half');
|
||||||
|
|||||||
Reference in New Issue
Block a user