move playsound function to target

This commit is contained in:
Eric Rosenbaum 2017-01-30 10:45:15 -05:00
parent d5e0d433aa
commit 4e57ab561d
2 changed files with 5 additions and 2 deletions

View file

@ -39,12 +39,12 @@ Scratch3SoundBlocks.prototype.getPrimitives = function () {
Scratch3SoundBlocks.prototype.playSound = function (args, util) { Scratch3SoundBlocks.prototype.playSound = function (args, util) {
var index = this._getSoundIndex(args.SOUND_MENU, util); var index = this._getSoundIndex(args.SOUND_MENU, util);
util.target.audioPlayer.playSound(index); util.target.playSound(index);
}; };
Scratch3SoundBlocks.prototype.playSoundAndWait = function (args, util) { Scratch3SoundBlocks.prototype.playSoundAndWait = function (args, util) {
var index = this._getSoundIndex(args.SOUND_MENU, util); var index = this._getSoundIndex(args.SOUND_MENU, util);
return util.target.audioPlayer.playSound(index); return util.target.playSound(index);
}; };
Scratch3SoundBlocks.prototype._getSoundIndex = function (soundName, util) { Scratch3SoundBlocks.prototype._getSoundIndex = function (soundName, util) {

View file

@ -465,6 +465,9 @@ RenderedTarget.prototype.updateAllDrawableProperties = function () {
this.runtime.spriteInfoReport(this); this.runtime.spriteInfoReport(this);
}; };
RenderedTarget.prototype.playSound = function (index) {
return this.audioPlayer.playSound(this.sprite.sounds[index].md5);
};
/** /**
* Return the human-readable name for this rendered target, e.g., the sprite's name. * Return the human-readable name for this rendered target, e.g., the sprite's name.
* @override * @override