mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
add get sound index by name
This commit is contained in:
parent
f2793a1d59
commit
f90807e8a4
1 changed files with 14 additions and 0 deletions
|
@ -381,6 +381,20 @@ RenderedTarget.prototype.getCostumeIndexByName = function (costumeName) {
|
|||
return -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a sound index of this rendered target, by name of the sound.
|
||||
* @param {?string} soundName Name of a sound.
|
||||
* @return {number} Index of the named sound, or -1 if not present.
|
||||
*/
|
||||
RenderedTarget.prototype.getSoundIndexByName = function (soundName) {
|
||||
for (var i = 0; i < this.sprite.sounds.length; i++) {
|
||||
if (this.sprite.sounds[i].name == soundName) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get a costume of this rendered target by id.
|
||||
* @return {object} current costume
|
||||
|
|
Loading…
Reference in a new issue