mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-25 07:22:33 -05:00
Use target volume, not custom state
This commit is contained in:
parent
a7c6c430b8
commit
f8c2771776
1 changed files with 4 additions and 8 deletions
|
@ -37,7 +37,6 @@ class Scratch3SoundBlocks {
|
||||||
*/
|
*/
|
||||||
static get DEFAULT_SOUND_STATE () {
|
static get DEFAULT_SOUND_STATE () {
|
||||||
return {
|
return {
|
||||||
volume: 100,
|
|
||||||
effects: {
|
effects: {
|
||||||
pitch: 0,
|
pitch: 0,
|
||||||
pan: 0
|
pan: 0
|
||||||
|
@ -267,22 +266,19 @@ class Scratch3SoundBlocks {
|
||||||
}
|
}
|
||||||
|
|
||||||
changeVolume (args, util) {
|
changeVolume (args, util) {
|
||||||
const soundState = this._getSoundState(util.target);
|
const volume = Cast.toNumber(args.VOLUME) + util.target.volume;
|
||||||
const volume = Cast.toNumber(args.VOLUME) + soundState.volume;
|
|
||||||
this._updateVolume(volume, util);
|
this._updateVolume(volume, util);
|
||||||
}
|
}
|
||||||
|
|
||||||
_updateVolume (volume, util) {
|
_updateVolume (volume, util) {
|
||||||
const soundState = this._getSoundState(util.target);
|
|
||||||
volume = MathUtil.clamp(volume, 0, 100);
|
volume = MathUtil.clamp(volume, 0, 100);
|
||||||
soundState.volume = volume;
|
util.target.volume = volume;
|
||||||
if (util.target.audioPlayer === null) return;
|
if (util.target.audioPlayer === null) return;
|
||||||
util.target.audioPlayer.setVolume(soundState.volume);
|
util.target.audioPlayer.setVolume(util.target.volume);
|
||||||
}
|
}
|
||||||
|
|
||||||
getVolume (args, util) {
|
getVolume (args, util) {
|
||||||
const soundState = this._getSoundState(util.target);
|
return util.target.volume;
|
||||||
return soundState.volume;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
soundsMenu (args) {
|
soundsMenu (args) {
|
||||||
|
|
Loading…
Reference in a new issue