refactored IDE ways to create new sprites

pull/95/head
jmoenig 2020-04-29 18:38:21 +02:00
rodzic 04e5444ced
commit 2b70a169e8
1 zmienionych plików z 8 dodań i 12 usunięć

Wyświetl plik

@ -2179,10 +2179,8 @@ IDE_Morph.prototype.selectSprite = function (sprite) {
if ( if (
detect( detect(
this.world().children, this.world().children,
function (morph) { morph => morph instanceof BlockEditorMorph ||
return morph instanceof BlockEditorMorph || morph instanceof BlockDialogMorph
morph instanceof BlockDialogMorph;
}
) )
) { ) {
return; return;
@ -2401,8 +2399,7 @@ IDE_Morph.prototype.addNewSprite = function () {
IDE_Morph.prototype.paintNewSprite = function () { IDE_Morph.prototype.paintNewSprite = function () {
var sprite = new SpriteMorph(this.globalVariables), var sprite = new SpriteMorph(this.globalVariables),
cos = new Costume(), cos = new Costume();
myself = this;
sprite.name = this.newSpriteName(sprite.name); sprite.name = this.newSpriteName(sprite.name);
sprite.setCenter(this.stage.center()); sprite.setCenter(this.stage.center());
@ -2414,8 +2411,8 @@ IDE_Morph.prototype.paintNewSprite = function () {
this.world(), this.world(),
this, this,
true, true,
function () {myself.removeSprite(sprite); }, () => this.removeSprite(sprite),
function () { () => {
sprite.addCostume(cos); sprite.addCostume(cos);
sprite.wearCostume(cos); sprite.wearCostume(cos);
} }
@ -2424,8 +2421,7 @@ IDE_Morph.prototype.paintNewSprite = function () {
IDE_Morph.prototype.newCamSprite = function () { IDE_Morph.prototype.newCamSprite = function () {
var sprite = new SpriteMorph(this.globalVariables), var sprite = new SpriteMorph(this.globalVariables),
camDialog, camDialog;
myself = this;
sprite.name = this.newSpriteName(sprite.name); sprite.name = this.newSpriteName(sprite.name);
sprite.setCenter(this.stage.center()); sprite.setCenter(this.stage.center());
@ -2437,8 +2433,8 @@ IDE_Morph.prototype.newCamSprite = function () {
camDialog = new CamSnapshotDialogMorph( camDialog = new CamSnapshotDialogMorph(
this, this,
sprite, sprite,
function () { myself.removeSprite(sprite); }, () => this.removeSprite(sprite),
function (costume) { function (costume) { // needs to be "function" to it can access "this"
sprite.addCostume(costume); sprite.addCostume(costume);
sprite.wearCostume(costume); sprite.wearCostume(costume);
this.close(); this.close();