A Hat Block, also called an Event Block, is a 积木 that is designed to start a 程式. This makes them essential for making 专案. All the 半圆形积木 are either 控制类积木 or 事件类积木. In the 实验查看器, the first word of their name is capitalised.
半圆形积木 are useful in 事件驱动程式设计 .
As 半圆形积木 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 半圆形积木 are the same as 堆叠式积木.
点击绿旗时 // 这就是半圆形积木. 定位到 [鼠标 v] 位置
There are eleven 半圆形积木 in Scratch. Four are used for extensions. They are:
當 @greenflag 被點擊 重複無限次 等待直到 <condition> 廣播訊息 [true v] 等待直到 <<condition> 不成立> end
當收到訊息 [true v] . . .
Without 半圆形积木, 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 绿旗 is clicked, a key is pressed, the 角色 is clicked, or when a broadcast is received.
An example for when the When I Receive () block can be used as follows:
當收到訊息 [Next Level v] 造型換成下一個
Snap! Hat 积木相关
In the Scratch Modification Snap!, 半圆形积木 are used in definitions of Custom Blocks (procedures). These 半圆形积木 contain an image of the block on them. The custom block carries out the script attached to the bottom of the hat block.
半圆形积木 cannot be created in BYOB 3.1, but may be available in BYOB/Snap! 4.0.