From bc64e6ed3e7f950c8b4825bfa7063936252812a7 Mon Sep 17 00:00:00 2001 From: DD Date: Thu, 11 Jan 2018 11:28:21 -0500 Subject: [PATCH 1/2] Unique sprite and backdrop names --- src/virtual-machine.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index 7b997dbdd..d1d8c2a14 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -268,6 +268,8 @@ class VirtualMachine extends EventEmitter { targets.forEach(target => { this.runtime.targets.push(target); (/** @type RenderedTarget */ target).updateAllDrawableProperties(); + // Ensure unique sprite name + if (target.isSprite()) this.renameSprite(target.id, target.getName()); }); // Select the first target for editing, e.g., the first sprite. if (wholeProject && (targets.length > 1)) { @@ -448,7 +450,7 @@ class VirtualMachine extends EventEmitter { addBackdrop (md5ext, backdropObject) { return loadCostume(md5ext, backdropObject, this.runtime).then(() => { const stage = this.runtime.getTargetForStage(); - stage.sprite.costumes.push(backdropObject); + stage.addCostume(backdropObject); stage.setCostume(stage.sprite.costumes.length - 1); }); } From 7ed58da1cff4517f8917ee5f3dd1817c59265236 Mon Sep 17 00:00:00 2001 From: DD Date: Thu, 11 Jan 2018 16:43:18 -0500 Subject: [PATCH 2/2] fix set editing target function --- src/virtual-machine.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/virtual-machine.js b/src/virtual-machine.js index d1d8c2a14..61b61e518 100644 --- a/src/virtual-machine.js +++ b/src/virtual-machine.js @@ -631,7 +631,7 @@ class VirtualMachine extends EventEmitter { */ setEditingTarget (targetId) { // Has the target id changed? If not, exit. - if (targetId === this.editingTarget.id) { + if (this.editingTarget && targetId === this.editingTarget.id) { return; } const target = this.runtime.getTargetById(targetId);