From Test-Scratch-Wiki

Color () is Touching ()?
2.0 Color () is Touching Color ().png
Category Sensing
Type Boolean

The Color () is Touching ()? block is a Sensing block and a Boolean block. The block checks if a color on its sprite is touching another color; if the color on its sprite is touching the color, the block returns true; if it is not, it returns false.

The color in a color square can be chosen by clicking on the color square and then clicking anywhere in the Scratch editor.

The block as seen in Scratch 1.2

In versions of Scratch before 1.2, this block was called Color () is Over ()?.

Example Uses

As this block detects if a color on its sprite is touching a color, it is widely used in collision detecting.

Some common uses for the Color () is Touching ()? block:

  • Moving a sprite until a color on its sprite touches a color
repeat until <color [#ea235c] is touching [#cba81a]?>
point towards [Sprite2 v]
move (10) steps
  • Making a sprite do things if a part of a sprite touches a color; for example, if the sprite's mouth touches blue (water), it drinks some water
if <color [#ffffff] is touching [#0000ff]?> then
switch to costume [drinking water v]
wait (1) secs
switch to costume [not drinking water v]
  • Stopping bullets when they hit walls of a specific color
if <color [#ffd700] is touching [#f321a5]?> then
  • In a maze, sensing if a sprite has hit a dead-end
if <color [#000000] is touching [#007f00]?> then
say [Uh-oh, I hit a dead end!] for (2) secs

See Also

Cookies help us deliver our services. By using our services, you agree to our use of cookies.