4.1.2 Mouse down block

View

The mouse down block checks if the mouse is being pressed. It is a useful block as a substitute for click detection. It is frequently used in one sprite one script projects.  If the project requires clicking, this block can be used to serve as a replacement for the “when clicked” block, as the hat block cannot be used in the middle of a script.

A common use for the mouse down block is sensing.


This sensing block will respond when the right mouse button is clicked. This means that you can have a sprite respond to user interaction. This is another example of event driven programming.  Event driven programming is a programming model in which the flow of the program is determined by events such as user actions, sensor outputs, or messages from other programs. The script will execute when the mouse button is clicked. 

 

Example

In this example the sprite will say “you touched me” and turn 15 degrees every time you click on the sprite.

Figure 106: Script where the Sprite says “you touched me”

Last modified: Wednesday, 29 September 2021, 4:30 PM