mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Add delete costume and sound functions to the vm public api
This commit is contained in:
parent
e9c48d250b
commit
73cb823199
1 changed files with 25 additions and 0 deletions
|
@ -286,6 +286,20 @@ class VirtualMachine extends EventEmitter {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a costume from the current editing target.
|
||||
* @param {int} costumeIndex - the index of the costume to be removed.
|
||||
*/
|
||||
deleteCostume (costumeIndex) {
|
||||
this.editingTarget.sprite.costumes = this.editingTarget.sprite.costumes
|
||||
.slice(0, costumeIndex)
|
||||
.concat(this.editingTarget.sprite.costumes.slice(costumeIndex + 1));
|
||||
if (costumeIndex === this.editingTarget.currentCostume) {
|
||||
this.editingTarget.setCostume(costumeIndex - 1);
|
||||
}
|
||||
this.emitTargetsUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a sound to the current editing target.
|
||||
* @param {!object} soundObject Object representing the costume.
|
||||
|
@ -298,6 +312,17 @@ class VirtualMachine extends EventEmitter {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a sound from the current editing target.
|
||||
* @param {int} soundIndex - the index of the sound to be removed.
|
||||
*/
|
||||
deleteSound (soundIndex) {
|
||||
this.editingTarget.sprite.sounds = this.editingTarget.sprite.sounds
|
||||
.slice(0, soundIndex)
|
||||
.concat(this.editingTarget.sprite.sounds.slice(soundIndex + 1));
|
||||
this.emitTargetsUpdate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a backdrop to the stage.
|
||||
* @param {string} md5ext - the MD5 and extension of the backdrop to be loaded.
|
||||
|
|
Loading…
Reference in a new issue