mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-28 22:30:40 -04:00
Use the new note picker field in music and EV3 extensions (#1720)
* Add note field type * Note picker in music extension plays notes * Use note picker in EV3 beep block
This commit is contained in:
parent
eef1885fad
commit
2cff4159bb
4 changed files with 36 additions and 4 deletions
|
@ -910,6 +910,9 @@ class Scratch3Ev3Blocks {
|
|||
|
||||
// Create a new EV3 peripheral instance
|
||||
this._peripheral = new EV3(this.runtime, Scratch3Ev3Blocks.EXTENSION_ID);
|
||||
|
||||
this._playNoteForPicker = this._playNoteForPicker.bind(this);
|
||||
this.runtime.on('PLAY_NOTE', this._playNoteForPicker);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1089,7 +1092,7 @@ class Scratch3Ev3Blocks {
|
|||
blockType: BlockType.COMMAND,
|
||||
arguments: {
|
||||
NOTE: {
|
||||
type: ArgumentType.NUMBER,
|
||||
type: ArgumentType.NOTE,
|
||||
defaultValue: 60
|
||||
},
|
||||
TIME: {
|
||||
|
@ -1212,6 +1215,14 @@ class Scratch3Ev3Blocks {
|
|||
return this._peripheral.brightness;
|
||||
}
|
||||
|
||||
_playNoteForPicker (note, category) {
|
||||
if (category !== this.getInfo().name) return;
|
||||
this.beep({
|
||||
NOTE: note,
|
||||
TIME: 0.25
|
||||
});
|
||||
}
|
||||
|
||||
beep (args) {
|
||||
const note = MathUtil.clamp(Cast.toNumber(args.NOTE), 47, 99); // valid EV3 sounds
|
||||
let time = Cast.toNumber(args.TIME) * 1000;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue