User Guide

86
There is a special set of operators in the Sensing section of the
Blocks Palette that you can use for making decisions based on
keyboard or mouse input from the user. Unlike the control
blocks, these blocks must be used as part of an if decision or with
a Boolean operator block.
You can use them in combination with the control blocks. For
example, to create two different actions depending on whether
the user clicks a sprite normally or holds the up arrow key when
they click a sprite.
Detecting a Collision between Sprites
A collision is when two sprites overlap each other on the screen.
The blocks that you need are in the Sensing section of the Blocks
Palette, and there are two ways you can detect a collision in
Scratch:
• Use touching to check if sprites are touching; or
• Use the touching color and color touching color
blocks.
Checking if two colors touch is useful in games when you need
to know if a specific part of a sprite is making contact with a
specific part of another. But because Scratch is programmed to
ignore transparent areas of your sprites, the touching block is all
you need for many games.
Block Description
mouse down? A Boolean value that is true if the user is currently
holding the left mouse button down.
key ? is pressed? A Boolean value that is true if the user is currently
pressing the specified key on the keyboard.
The touching block does not detect collisions when sprites are
hidden with the hide block. However, it does detect collisions
when sprites are made invisible using the ghost effect.