Skip to content

Commit

Permalink
part of #727
Browse files Browse the repository at this point in the history
  • Loading branch information
GarboMuffin committed Aug 8, 2023
1 parent 8170227 commit be1ed13
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions extensions/JeremyGamer13/tween.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,37 @@
menu: 'direction'
}
}
},
{
opcode: 'tweenProperty',
text: 'tween [PROPERTY] from [START] to [END] over [SEC] seconds using [MODE] ease [DIRECTION]',
blockType: BlockType.COMMAND,
arguments: {
PROPERTY: {
type: ArgumentType.STRING,
menu: 'properties'
},
START: {
type: ArgumentType.NUMBER,
defaultValue: 0
},
END: {
type: ArgumentType.NUMBER,
defaultValue: 100
},
SEC: {
type: ArgumentType.NUMBER,
defaultValue: 1
},
MODE: {
type: ArgumentType.STRING,
menu: 'modes'
},
DIRECTION: {
type: ArgumentType.STRING,
menu: 'direction'
}
}
}
],
menus: {
Expand All @@ -326,7 +357,17 @@
]
},
vars: {
acceptReporters: false, // for Scratch parity
items: 'getVariables'
},
properties: {
acceptReporters: true,
items: [
'x position',
'y position',
'direction',
'size'
]
}
}
};
Expand Down Expand Up @@ -413,6 +454,20 @@
}
});
}

tweenProperty(args, util) {
this._tweenValue(args, util, value => {
if (args.PROPERTY === 'x position') {
util.target.setXY(value, util.target.y);
} else if (args.PROPERTY === 'y position') {
util.target.setXY(util.target.x, value);
} else if (args.PROPERTY === 'direction') {
util.target.setDirection(value);
} else if (args.PROPERTY === 'size') {
util.target.setSize(value);
}
});
}
}

Scratch.extensions.register(new Tween());
Expand Down

0 comments on commit be1ed13

Please sign in to comment.