ScratchLearningResource MyBlocks
ScratchLearningResource MyBlocks
Blocks
Have you seen the “My Blocks” category in the Scratch blocks palette? When you
click on it, no blocks are present until you create one. Let’s explore how to create a
customized block and when and why you might want to use them.
Since the program pauses to perform all the code defined under a
custom block before moving on, if you put a forever block under a
custom My Block, it will never get to the next code blocks in the main
program. It is best to use a broadcast for code that runs forever.
If the refresh is happening at the right speed, your eyes should perceive continuous motion and
you can see all the intermediate steps as the program progresses. But if the sequence runs
quickly between refreshes, your eyes will not be able to perceive the action and you’ll only see
the finished product. Sometimes we may want to see each step, and sometimes we may just
want the result. (See https://scratch.mit.edu/projects/921473501 or
https://scratch.mit.edu/projects/921541090 for examples of with or without screen refresh.)
When you check to “Run without screen refresh,” Scratch will attempt to run the
script as fast as possible (in one frame) and will not refresh the screen until it has
finished executing all the steps in the procedure. If you’ve used turbo mode before in
Scratch, it is a similar concept, but turbo mode applies to the entire program, while “Run
without screen refresh” only applies to the procedure in your custom block.
One important note is that if any of the blocks in your custom block involve time, you should
not use “Run without screen refresh.” Because the program needs to honor the time, trying to
run the code without refreshing could cause a lag, screen freezes, or even program crashes.
If you are using more than one input in your block, you can
also add labels (descriptive text) between the inputs to
help you remember what each input bubble is for when
you use it in your main program.
You can:
● Create multiple custom blocks, with or without inputs, to use throughout your program.
● Use a custom block inside another custom block.
(Example: https://scratch.mit.edu/projects/921283811)
● Combine broadcast blocks and custom blocks, depending on your needs, to create a
dynamic program! (Example: https://scratch.mit.edu/projects/921470324)