getting started with scratch

sensing

Sensing

The blocks in the Sensing blocks menu are used to get user text input, detect conditions, and report on values in your project.

There are several hexagonal Sensing blocks that you can use in Control blocks to make decisions and control when blocks run.

The touching block has options for detecting whether the sprite that owns the script is touching the mouse pointer (where you finger last touched on a tablet), the edge of the Stage, or another sprite:

 

 

 

 

 

 

There are blocks for detecting whether the sprite that owns the script is touching another colour (on the Stage or another sprite), or whether a colour on this sprite is touching another colour.

 

 

 

 

The key pressed block has options for number, letter, and arrow keys. You need a keyboard to be able to enter keys. It detects whether the key is currently being pressed:

 

 

The mouse down block detects whether the mouse is currently pressed, or the screen is being tapped or touched on a touchscreen:

 

 

 

 

 

 

 

The ask block works with a keyboard or with a virtual on-screen keyboard on a tablet.

The answer block is a reporter block that reports a value and can be used as a variable.

Chat using ask and answer

You can use the ask and answer blocks from the Sensing blocks menu to have a conversation.

Ask dialogue with yes as input

Add blocks to a script on the sprite that will ask a question:

 

 

 

 

 

 

 

 

Debug: Check that you have spelled the options correctly in your code and in your answer. It’s okay if you use capital letters, so “Yes” and “YES” will match “yes”.

Add multiple questions to create a chatbot or non-player character that you can talk to.

Tip: If you hide the sprite that asks a question, then question will appear inside the input box instead of as a speech bubble.

Ask dialogue with question inside