mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-01-11 10:39:56 -05:00
Merge pull request #975 from ericrosenbaum/bugfix/move-volume-to-rendered-target
Move volume to rendered target
This commit is contained in:
commit
2b985fa083
3 changed files with 12 additions and 10 deletions
|
@ -238,7 +238,7 @@ class Scratch3SensingBlocks {
|
|||
case 'backdrop #': return attrTarget.currentCostume + 1;
|
||||
case 'backdrop name':
|
||||
return attrTarget.getCostumes()[attrTarget.currentCostume].name;
|
||||
case 'volume': return; // @todo: Keep this in mind for sound blocks!
|
||||
case 'volume': return attrTarget.volume;
|
||||
}
|
||||
} else {
|
||||
switch (args.PROPERTY) {
|
||||
|
@ -249,7 +249,7 @@ class Scratch3SensingBlocks {
|
|||
case 'costume name':
|
||||
return attrTarget.getCostumes()[attrTarget.currentCostume].name;
|
||||
case 'size': return attrTarget.size;
|
||||
case 'volume': return; // @todo: above, keep in mind for sound blocks..
|
||||
case 'volume': return attrTarget.volume;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,6 @@ class Scratch3SoundBlocks {
|
|||
*/
|
||||
static get DEFAULT_SOUND_STATE () {
|
||||
return {
|
||||
volume: 100,
|
||||
effects: {
|
||||
pitch: 0,
|
||||
pan: 0
|
||||
|
@ -267,22 +266,19 @@ class Scratch3SoundBlocks {
|
|||
}
|
||||
|
||||
changeVolume (args, util) {
|
||||
const soundState = this._getSoundState(util.target);
|
||||
const volume = Cast.toNumber(args.VOLUME) + soundState.volume;
|
||||
const volume = Cast.toNumber(args.VOLUME) + util.target.volume;
|
||||
this._updateVolume(volume, util);
|
||||
}
|
||||
|
||||
_updateVolume (volume, util) {
|
||||
const soundState = this._getSoundState(util.target);
|
||||
volume = MathUtil.clamp(volume, 0, 100);
|
||||
soundState.volume = volume;
|
||||
util.target.volume = volume;
|
||||
if (util.target.audioPlayer === null) return;
|
||||
util.target.audioPlayer.setVolume(soundState.volume);
|
||||
util.target.audioPlayer.setVolume(util.target.volume);
|
||||
}
|
||||
|
||||
getVolume (args, util) {
|
||||
const soundState = this._getSoundState(util.target);
|
||||
return soundState.volume;
|
||||
return util.target.volume;
|
||||
}
|
||||
|
||||
soundsMenu (args) {
|
||||
|
|
|
@ -122,6 +122,12 @@ class RenderedTarget extends Target {
|
|||
* @type {number}
|
||||
*/
|
||||
this.tempo = 60;
|
||||
|
||||
/**
|
||||
* Loudness for sound playback for this target, as a percentage.
|
||||
* @type {number}
|
||||
*/
|
||||
this.volume = 100;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue