Page 127 - KEC Khaitan C3 Flipbook
P. 127

SENSING BLOCKS


                 Sensing blocks in Scratch sense the input from the keyboard or the mouse at the
                 time of execution of a script.

                 Some of the sensing blocks and their functions are given below:



                              Blocks                                          Function



                                                      This block checks if the Sprite touches the mouse-
                                                      pointer, another Sprite or the edge. If the answer is
                                                      true, then it executes the blocks given after it in the

                                                      condition. If false, then it executes other blocks as
                                                      per the given condition.

                                                      This block checks if the Sprite is touching the colour
                                                      chosen in the block. If true, then it executes a set of

                                                      blocks, else executes another set of blocks.

                                                      This block checks if the first chosen colour is touching
                                                      the second chosen colour. If true, then it executes a
                                                      set of blocks, else executes another set of blocks.



                                                      This block returns True if any of the mouse buttons
                                                      are being pressed while the cursor is over the stage.


                                                      This block checks if the chosen key is pressed by

                                                      the user. If true, then it executes a set of blocks, else
                                                      executes another set of blocks.

                 Let us make a small script.

                 Change  the  Sprite  to  fish  and  change  the
                 backdrop to Underwater 2.

                 Drag the Events block, when green flag clicked

                 to the script area. Drag the control block, forever
                 to the script area and put it to the green flag
                 block. Drag the move block and put it inside the
                 forever block. Now, drag the if on edge, bounce
                 block and put it inside the forever block.




                                                                                             Interactivity and Logic  125
   122   123   124   125   126   127   128   129   130   131   132