Zho:碰到颜色 ()？（积木）

The Touching Color ? 积木 is a 侦测类积木 block and a 菱形积木. The block checks if its 角色 is touching the specified color. If the sprite is touching the color, the block returns "true"; triggering the rest of the script to continue. If it is not, it returns "false" the script remains neutral.

The color can be chosen by clicking on the block's color square, and then clicking anywhere in the Scratch 专案. For example, if the mouse was hovering over the color: blue and was clicked the color square would turn blue.

用法示例
As this block detects if a color on its sprite is touching a color, it is widely used in collision detecting. 游戏平台s often use this block.

Some common uses for the Touching Color ? block: 重複直到 <碰到顏色 [#000000] ?> 移動 (10) 點 end 如果 <碰到顏色 [#0000FF] ?> 那麼 說出 [I found water!] (2) 秒 end
 * Moving a sprite until it touches a color
 * Making a sprite do things if it touches a color for example, if the sprite touches blue (water), it reacts in a specific way
 * Stopping bullets when they hit walls of a specific color

重複無限次 如果 <碰到顏色 [#ff0000] ?> 那麼 隱藏 end end


 * In a maze, sensing if a sprite has hit a dead-end

重複無限次 如果 <碰到顏色 [#007f00] ?> 那麼 說出 [Dead end!] (1) 秒 end end


 * Making sprites not go through walls

重複無限次 如果 <碰到顏色 [#ffff7f] ?> 那麼 變數 [x velocity v] 設為 (0) end end


 * Making Game End when touching color

重複無限次 如果 <碰到顏色 [#01efff] ?> 那麼 說出 [Game Over] (1) 秒 廣播訊息 [Game Over v] end end

参见

 * 颜色 碰到颜色 ？