add get sound index by name

This commit is contained in:
Eric Rosenbaum 2016-12-21 16:42:19 -05:00
parent f2793a1d59
commit f90807e8a4

View file

@ -381,6 +381,20 @@ RenderedTarget.prototype.getCostumeIndexByName = function (costumeName) {
return -1; 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. * Get a costume of this rendered target by id.
* @return {object} current costume * @return {object} current costume