Activa JavaScript para disfrutar de los vídeos de la Mediateca.
20 blocks 1 - Contenido educativo
Ajuste de pantallaEl ajuste de pantalla se aprecia al ver el vídeo en pantalla completa. Elige la presentación que más te guste:
Have you seen the My Blocks category in the Scratch Blocks palette?
00:00:00
When you click on it, no blocks are present until you create one.
00:00:13
Let's explore how to create a customized block, and when and why you might want to use them.
00:00:17
Let's say you are creating a Scratch program, and you've written a sequence of steps that performs a particular action.
00:00:22
That action could be performing a complicated spin move, playing a set of musical notes,
00:00:28
drawing a shape with the pen tool, performing some complex math, or anything
00:00:33
else. That stack of blocks is known as a procedure or a routine. Most computer
00:00:38
programming languages allow you to create a special name for a group of
00:00:44
commands or lines of code and then call for that sequence to run at any point in
00:00:47
the main program. In Scratch, we use my blocks. Click on my blocks in the blocks
00:00:52
palette and then click on make a block. You can give your block any name you
00:00:58
want, but I'd recommend something descriptive, so you can recall later what this stack of
00:01:02
blocks does.
00:01:06
Let's say I want to create a series of blocks that makes my cat sprite spin forward and
00:01:07
backward.
00:01:12
I'll call my block Cat Spin.
00:01:13
Once I click OK, you'll see a new Event Handler block appears on the Scripts area
00:01:15
that says Define.
00:01:20
Under this block, I want to add all the code blocks in my procedure.
00:01:22
For this example, I've added some repeating code that makes the cat whirl and turn forward
00:01:27
in two complete circles, and then reverse the world, turning in the opposite direction.
00:01:32
Let's click on this stack and see how it looks.
00:01:37
Now that I have defined what my custom block does, let's use it in my main program.
00:01:41
When I want the spin to occur, I'll grab my custom cat spin block,
00:01:46
now available in the Blocks palette, and place it in my main program.
00:01:50
In this program that I'm writing, the cat will spin after each background change,
00:01:54
and say something after the spin.
00:01:58
Let's see how this looks by clicking the green flag.
00:02:00
The advantage of writing this procedure separately is that I can use one block to call for a
00:02:09
whole set of steps to be run each time I need it.
00:02:14
Creating separate procedures using custom blocks makes the code faster to write and
00:02:18
read, and easier or quicker to edit.
00:02:22
If I wasn't using a custom block, this is how the code would look, looking at them side
00:02:25
by side, which is easier to read.
00:02:29
And look, if I wanted to change the spin, I only have to edit it in one place, versus
00:02:36
editing it in multiple places in my long, single code sequence.
00:02:41
You don't have to use a custom block just for code that will repeat.
00:02:46
- Idioma/s:
- Materias:
- Tecnología
- Etiquetas:
- Scratch
- Niveles educativos:
- ▼ Mostrar / ocultar niveles
- Educación Secundaria Obligatoria
- Ordinaria
- Primer Ciclo
- Primer Curso
- Segundo Curso
- Segundo Ciclo
- Tercer Curso
- Cuarto Curso
- Diversificacion Curricular 1
- Diversificacion Curricular 2
- Primer Ciclo
- Compensatoria
- Ordinaria
- Subido por:
- David G.
- Licencia:
- Todos los derechos reservados
- Visualizaciones:
- 6
- Fecha:
- 12 de diciembre de 2024 - 12:46
- Visibilidad:
- Público
- Centro:
- IES MARIE CURIE Loeches
- Duración:
- 02′ 50″
- Relación de aspecto:
- 1.78:1
- Resolución:
- 1920x1080 píxeles
- Tamaño:
- 12.71 MBytes