Hi,so im currently working on creating custom movement blocks like moveforward() and movleft() in order to animate caracter like the maze game from blockly so i created the blocks but when it comes to generating the code i want my caracter to move so i did this but i dont know if that is the right approche or i have to return the string code like where should i put the animation javascript function :
-----------------------------------------------------------------------------------------------------------
//this is the block definition
Blockly.Blocks.moveBackward = {
init() {
this.appendDummyInput().appendField('MoveBackward');
this.setInputsInline(false);
this.setPreviousStatement(true, null);
this.setNextStatement(true, null);
this.setColour(290);
this.setTooltip('');
this.setHelpUrl('');
},
};
//this is the animation function i want to execute when the move block is draged
moveBackward() {
player.setVelocityX(-150);
}
//and here's the block code generator
((Blockly as any).JavaScript['moveBackward'] = function (block) {
// TODO: Assemble JavaScript into code variable.
var code = moveBackward();
return code;
});
--------------------------------
So is it right what im doing or should i return string instead of moveBackward() function and where should i place my function ,please help me ,thank youu