mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2025-08-11 13:59:23 -04:00
Changes to src/virtual-machine based on minor bugs found during testing. This was supposed to be included with the previous commit.
This commit is contained in:
parent
bf6b78137a
commit
70081132cb
1 changed files with 6 additions and 2 deletions
|
@ -495,7 +495,11 @@ class VirtualMachine extends EventEmitter {
|
|||
// Ensure editing target is switched if we are deleting it.
|
||||
if (clone === currentEditingTarget) {
|
||||
const nextTargetIndex = Math.min(this.runtime.targets.length - 1, targetIndexBeforeDelete);
|
||||
this.setEditingTarget(this.runtime.targets[nextTargetIndex].id);
|
||||
if (this.runtime.targets.length > 0){
|
||||
this.setEditingTarget(this.runtime.targets[nextTargetIndex].id);
|
||||
} else {
|
||||
this.editingTarget = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Sprite object should be deleted by GC.
|
||||
|
@ -518,7 +522,7 @@ class VirtualMachine extends EventEmitter {
|
|||
} else if (!target.sprite) {
|
||||
throw new Error('No sprite associated with this target.');
|
||||
}
|
||||
target.duplicate().then(newTarget => {
|
||||
return target.duplicate().then(newTarget => {
|
||||
this.runtime.targets.push(newTarget);
|
||||
this.setEditingTarget(newTarget.id);
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue