Eng:Touching ()? (block)

The Touching ? block is a Sensing block and a Boolean block. The block checks if its sprite is touching the mouse-pointer, edge, or another sprite (a Reporter block holding the sprite's name can be used). If the sprite is touching the selected object, the block returns true; if it is not, it returns false.

This block behaves differently when the sprite is hidden. Every check for collisions with other sprites return false, however it still senses the mouse and the edges.

Example Uses
As the block checks if its sprite is touching an object, it is widely used in detecting collisions.

Some common uses for the Touching ? block: repeat until  move (3) steps end repeat until  point towards [Sprite2 v]  move (3) steps end say [I caught you!] for (2) secs
 * Moving a sprite until it touches the edge of the screen
 * Having a sprite chase another sprite until the chaser touches the runner
 * Stopping bullets when they hit walls

forever if  then hide


 * In a maze, sensing if a sprite has hit a dead-end

forever if  then say [Dead end!] for (1) secs

when flag clicked forever if  then switch to costume [highlighted v] else switch to costume [normal v] end
 * Checking if a sprite is touching the mouse pointer

forever if  then say [Game over!] stop [all v] end
 * Checking if the player has touched an enemy in a game

Related Suggestion
Some Scratchers want a block that detects if two different sprites are touching. The advantage of such a block is that it grants a 3rd sprite the ability to sense if another two are touching. Such a block would look similar to this:

<[sprite1 v] is touching [sprite2 v]?>//category=sensing

This can be replicated with a global variable, with one of the touching sprites checking, and setting the value, like so: // In Sprite1 when I receive [Check for Touching v] if  then set [Sprite1 Touching Sprite2? v] to [yes] else set [Sprite1 Touching Sprite2? v] to [no] end

// Anywhere you want to check for the touching broadcast [Check for Touching v] if <(Sprite1 Touching Sprite2?) = [yes]> then // put what you want if they're touching here else // put what you want if they aren't here end