Sensing

Extension Description
Sensing blocks are associate with sprites and stage detecting conditions.

Introduction

Sensing is one of the ten categories of default Scratch blocks. They are color-coded cyan and are used to detect different factors of a project.

Python Functions

The function checks if its sprite is touching the mouse-pointer, edge, or another sprite. If the sprite is touching the selected object, the block returns true; if it is not, it returns false.
Syntax: istouching(object_name = “_edge_”)
The function reports the Euclidean distance, in pixels, between it and the mouse-pointer or a specified sprite’s costume center.
Syntax: distance(object_name = “_edge_”)
The function will make an input box (with the specified text above it) show at the bottom of the screen. Users can input text into it and submit it, and the input is stored then in the Answer. The Answer automatic updates to the most recent input.
Syntax: input(question = “What is your name”)
The function returns the most recent text imputed with the input() function. When nothing has been inputted yet, the value will hold nothing.
Syntax: answer()
The function checks if the specified key is pressed. If the key is being pressed, the block returns “true”; if it is not, it returns “false”.
Syntax: iskeypressed(key = “space”)
The function reports the mouse pointer’s current X position on the stage.
Syntax: mousex()
The function reports the mouse pointer’s current y position on the stage.
Syntax: mousey()
The function reports how loud the noise that a microphone receives, on a scale of 0 to 100.
Syntax: loudness()
The function reports the time lapsed since the PictoBlox is launched and increases gradually; every second it will have increased by 1.
Syntax: timer()
The function sets the timer’s value back to 0. 
Syntax: resettimer()
The function reports the number of days (and fractions of a day) since 00:00:00 1 January 2000 (UTC).
Syntax: dayssince2000()
All articles loaded
No more articles to load

Python Coding Examples

PictoBlox Blocks

The block checks if its sprite is touching the mouse-pointer, edge, or another sprite. If the sprite is touching the selected object, the block returns true; if it is not, it returns false.
The block checks whether its sprite is touching a specified color. If it is, the block returns “true”.
The block checks whether a color on its sprite is touching another color. If it is, the block returns “true”.
The block reports the Euclidean distance, in pixels, between it and the mouse-pointer or a specified sprite’s costume center.
The block will make an input box (with the specified text above it) show at the bottom of the screen. Scratchers can input text into it and submit it, and the input is stored then in the Answer block. The Answer block automatic updates to the most recent input.
The block holds the most recent text imputed with the Ask () and Wait block. When nothing has been inputted yet, the value will hold nothing.
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 block checks if the computer mouse’s primary button is activated (being clicked).
The block holds (reports) the mouse-pointer’s current Mouse X.
The block holds the mouse-pointer’s current Mouse Y.
The block reports how loud the noise is that a microphone receives, on a scale of 0 to 100. To use this block, a microphone must be used, and so a message will appear on the screen, asking for permission to use the microphone. If you deny it, the block will report a loudness of 0 or -1.
The block starts at 0 when Scratch is launched and increases gradually; every second it will have increased by 1.
The block sets the timer’s value back to 0.0. When this block is present, the project typically utilizes the Timer output block; usually the timer must be reset at the beginning of a project for the Timer block to hold the right value.
The block will report a specified value of the specified sprite or the Stage.
It reports either the current local year, month, date, day of the week, hour, minutes, or seconds, depending on the argument. The block gets the data based on the user’s computer’s clock and set in 24-hour clock.
It reports the number of days (and fractions of a day) since 00:00:00 1 January 2000 (UTC).
All articles loaded
No more articles to load

Block Coding Examples

Table of Contents