workspaces folders
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import * as Blockly from "blockly";
|
||||
import { javascriptGenerator, Order } from "blockly/javascript";
|
||||
|
||||
Blockly.Blocks['physics_apply_impulse_action'] = {
|
||||
init(this: Blockly.Block) {
|
||||
this.appendDummyInput('')
|
||||
.appendField('Push me in direction of');
|
||||
this.appendValueInput('POSITION')
|
||||
.setCheck('DPos');
|
||||
this.appendDummyInput('')
|
||||
.appendField('with force')
|
||||
.appendField(new Blockly.FieldNumber(1, -10, 10, 0.01), 'FORCE');
|
||||
|
||||
|
||||
this.setInputsInline(true);
|
||||
this.setPreviousStatement(true, null);
|
||||
this.setNextStatement(true, null);
|
||||
this.setTooltip('Push me in a direction');
|
||||
this.setColour(150);
|
||||
}
|
||||
};
|
||||
|
||||
javascriptGenerator.forBlock['physics_apply_impulse_action'] = function (block, generator) {
|
||||
const positionValue = generator.valueToCode(block, 'POSITION', Order.ATOMIC);
|
||||
const forceValue = block.getFieldValue('FORCE');
|
||||
return `api.applyImpulse(${positionValue}, ${forceValue});\n`;
|
||||
};
|
||||
|
||||
export { };
|
||||
Reference in New Issue
Block a user