(Redirected from Eng:Hat Blocks)
A Hat Block, also called an Event Block, is a block that is designed to start a script. This makes them essential for making projects. All the hat blocks are either Control blocks or Events blocks. In the Experimental Viewer, the first word of their name is capitalised.
Hat blocks are useful in Event Based Programming.
As Hat blocks are designed to start a script, they are shaped so no blocks can go on top of them — this is done by rounding the blocks' top. The bottom of Hat blocks are the same as Stack blocks.
when gf clicked //This is a hat block. go to [mouse-pointer v]
There are eleven Hat blocks in Scratch. Four are used for extensions. They are:
- When Green Flag Clicked
- When () Key Pressed
- When This Sprite Clicked
- When I Receive ()
- When Backdrop Switches to ()
- When I Start as a Clone
- When () > ()
- When ()
- When Tilt = ()
- When Distance < ()
- When () () ()
when gf clicked forever wait until <condition> broadcast [true v] wait until <not <condition>>
when I receive [true v] . . .
Without Hat blocks, scripts could only be activated manually, and not at all online. Each Hat block has a different method for getting activated — this is so different scripts can be started at different times. There are four different ways to activate a script — when the Green Flag is clicked, a key is pressed, the sprite is clicked, or when a broadcast is received.
An example for when the When I Receive () block can be used as follows:
when I receive [Next Level v] next costume
Snap! Hat Blocks
In the Scratch Modification Snap!, hat blocks are used in definitions of Custom Blocks (procedures). These hat blocks contain an image of the block on them. The custom block carries out the script attached to the bottom of the hat block.
Hat blocks cannot be created in BYOB 3.1, but may be available in BYOB/Snap! 4.0.