From 9fce4d40d04af8d75541897b5f437a495688b6bf Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Tue, 5 Jun 2018 11:46:52 -0400 Subject: [PATCH] Fix bug with zero adding a costume/sound at index 0 --- src/sprites/rendered-target.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/sprites/rendered-target.js b/src/sprites/rendered-target.js index b6df05e6c..a21bfa4ab 100644 --- a/src/sprites/rendered-target.js +++ b/src/sprites/rendered-target.js @@ -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); } }