mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fix bug with zero adding a costume/sound at index 0
This commit is contained in:
parent
c2645f3da5
commit
9fce4d40d0
1 changed files with 6 additions and 6 deletions
|
@ -488,10 +488,10 @@ class RenderedTarget extends Target {
|
|||
* @param {?int} index Index at which to add costume
|
||||
*/
|
||||
addCostume (costumeObject, index) {
|
||||
if (index) {
|
||||
this.sprite.addCostumeAt(costumeObject, index);
|
||||
} else {
|
||||
if (typeof index === 'undefined') {
|
||||
this.sprite.addCostumeAt(costumeObject, this.sprite.costumes.length);
|
||||
} else {
|
||||
this.sprite.addCostumeAt(costumeObject, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -551,10 +551,10 @@ class RenderedTarget extends Target {
|
|||
addSound (soundObject, index) {
|
||||
const usedNames = this.sprite.sounds.map(sound => sound.name);
|
||||
soundObject.name = StringUtil.unusedName(soundObject.name, usedNames);
|
||||
if (index) {
|
||||
this.sprite.sounds.splice(index, 0, soundObject);
|
||||
} else {
|
||||
if (typeof index === 'undefined') {
|
||||
this.sprite.sounds.push(soundObject);
|
||||
} else {
|
||||
this.sprite.sounds.splice(index, 0, soundObject);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue