Skip to content

Commit 4b9038d

Browse files
authored
Merge pull request scratchfoundation#1046 from Kenny2github/patch-2
Add glide (number) secs to [drop down] block
2 parents a45d8ad + af9484c commit 4b9038d

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

blocks_vertical/default_toolbox.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,17 @@ Blockly.Blocks.defaultToolbox = '<xml id="toolbox-categories" style="display: no
9999
'</shadow>'+
100100
'</value>'+
101101
'</block>'+
102+
'<block type="motion_glideto" id="motion_glideto">'+
103+
'<value name="SECS">'+
104+
'<shadow type="math_number">'+
105+
'<field name="NUM">1</field>'+
106+
'</shadow>'+
107+
'</value>'+
108+
'<value name="TO">'+
109+
'<shadow type="motion_glideto_menu">'+
110+
'</shadow>'+
111+
'</value>'+
112+
'</block>'+
102113
'<block type="motion_changexby" id="motion_changexby">'+
103114
'<value name="DX">'+
104115
'<shadow type="math_number">'+

blocks_vertical/motion.js

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,56 @@ Blockly.Blocks['motion_glidesecstoxy'] = {
265265
}
266266
};
267267

268+
Blockly.Blocks['motion_glideto_menu'] = {
269+
/**
270+
* Glide to drop-down menu
271+
* @this Blockly.Block
272+
*/
273+
init: function() {
274+
this.jsonInit({
275+
"message0": "%1",
276+
"args0": [
277+
{
278+
"type": "field_dropdown",
279+
"name": "TO",
280+
"options": [
281+
['mouse-pointer', '_mouse_'],
282+
['random position', '_random_']
283+
]
284+
}
285+
],
286+
"colour": Blockly.Colours.motion.secondary,
287+
"colourSecondary": Blockly.Colours.motion.secondary,
288+
"colourTertiary": Blockly.Colours.motion.tertiary,
289+
"extensions": ["output_string"]
290+
});
291+
}
292+
};
293+
294+
Blockly.Blocks['motion_glideto'] = {
295+
/**
296+
* Block to glide to a menu item
297+
* @this Blockly.Block
298+
*/
299+
init: function() {
300+
this.jsonInit({
301+
"message0": "glide %1 secs to %2",
302+
"args0": [
303+
{
304+
"type": "input_value",
305+
"name": "SECS"
306+
},
307+
{
308+
"type": "input_value",
309+
"name": "TO"
310+
}
311+
],
312+
"category": Blockly.Categories.motion,
313+
"extensions": ["colours_motion", "shape_statement"]
314+
});
315+
}
316+
};
317+
268318
Blockly.Blocks['motion_changexby'] = {
269319
/**
270320
* Block to change X.

0 commit comments

Comments
 (0)