The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.

A simple documentation for scratch programming.

Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by Leo Voon, 2019-11-06 23:30:11

Scratch Sensing Blocks

A simple documentation for scratch programming.

Keywords: sensing,scratch,block,programming

1

Sensing Blocks - Scratch Touching ()? block checks if its
Touching ()? block sprite is touching the

If touching mouse-pointer mouse-pointer, edge, or another
sprite.
If touching edge
If the sprite is touching the
selected object,
it returns TRUE,

If it is not, returns FALSE.

If touching another sprite Example Uses

Checking if a player Moving a sprite until
has touched an it touches the edge
enemy in a game of the screen

Change costume
when touching with
mouse-pointer

2

Sensing Blocks - Scratch
Touching Color ()? (block)

The block checks whether its
sprite is touching a specified
color. If it is, the block returns

TRUE.

Use Color Picker or Eyedropper to set color
Example Uses

Moving a sprite until it
touches a color

Making a sprite do
something if it
touches a color

Sensing whether a
sprite has hit a
dead-end in a maze.

3

Sensing Blocks - Scratch
Color () is Touching ()? (block)

The block checks whether the first input, a color on its
sprite, is touching another color. If it is, the block reports

TRUE.

Example Uses

Moving a sprite until a
color on its sprite
touches a color

Making a sprite do
something if a color on
its sprite touches a color

More Info

4

Sensing Blocks - Scratch
Distance to () (block)

The block reports the distance, in pixels, between it and the
mouse-pointer or a specified sprite's costume center.

Distance between sprite and mouse-pointer

Distance between sprite and another sprite

5

Sensing Blocks - Scratch

Ask () and Wait (block)

The block will make an input box (with
the specified text above it) show at the

bottom of the screen

stored in

Answer (block)

Scratchers can input text
into it and submit it, and the

input is stored then in the
Answer block.

Tick checkbox besides Answer block to view its value

6

Sensing Blocks - Scratch and
Example Uses

Receiving information
from the user and print
it out

Setting preferences — Receiving input — asking the
coordinates, color, and user to give a command
so on
How to make a variable ?
Store information to variable
2

1

7

Sensing Blocks - Scratch
Key () Pressed? (block)

The block checks if the specified key is pressed. If the key is being
pressed, the block returns TRUE; if it is not, it returns FALSE.

The keys available to be used in this block include
The English alphabet
number keys
arrow keys
and the space key
Example Uses

• Controlling a character
Make a sprite move 4 directions
by pressing arrow key

8

Sensing Blocks - Scratch
Mouse Down? (block)

The block checks if the computer mouse's primary button is
activated (being clicked and held).

Mouse ONE

Mouse X and Y (block)

The block reports the mouse-pointer's current
Mouse X or Mouse Y coordinates.

Watch carefully that
the mouse-pointer is
currently at 0,0.

X:0
Y:0

9

Sensing Blocks - Scratch
Set drag mode (block)

The block can be used to
make a sprite draggable or

disable the drag mode.

Loudness (block)

The block reports how loud the
noise is that a microphone

receives, on a scale of 0 to 100.

10

Sensing Blocks - Scratch

Timer (block)

The block starts at 0 when Scratch is launched and
increases gradually; every second it will have

increased by 1. This block is almost always used with
the Reset Timer block

Reset timer (block)

The block sets the timer's value back to 0.0.

Backdrop () (block)

The block reports the
backdrop index, backdrop
name, backdrop volume or
variable’s value of the Stage.

Index/Number name

volume variable

11

Sensing Blocks - Scratch
Current () (block)

The block reports either the current local
year, month, date, day of the week, hour,

minute, or second, depending on the
argument.

Days Since 2000 (block)

The block reports the amount of days (and
fractions of a day) since 00:00:00 1
January 2000 (UTC).

Username (block)

The block reports the username of the user
viewing the project. If no user is signed in,

this block returns the empty string.

12

Sensing Blocks - Scratch

Let’s Do This

1 Flying cat move towards apple, when it hits apple, it says
“I found Apple”. Code by using touching color blocks.

2 Make a butterfly move forward in any direction. It
stops and changes color when hitting edge.

Butterfly 1

A parrot sprite can be moved by pressing arrows
3 key. When parrot found a glass of water. The glass

of water disappear.

Parrot A glass of water

13

Sensing Blocks - Scratch

Possible answer

1

Cat Flying

Happy learning !

2

Butterfly 1

Parrot

3

A glass of water

14


Click to View FlipBook Version