Page 63 - 2619_PlusGPT V2.1_C-6
P. 63

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

                                            block prompts the user to type the input using the keyboard. It waits for the

                   user input. No other block runs at that time.

                                          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.

                                   block checks if the sprite is touching the color chosen in the block. If true, then it

                   executes a set of blocks, else executes another set of blocks.

                                         The 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.


                                       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 create a small script to understand the working of sensing blocks.

                      Sensing an Input

                 To add sensing blocks to the script, follow the given steps:

                 Step 1:   Click on the Sensing block category in Tabs.
                 Step 2:   Insert a sprite, Penguin2 on the stage. Delete the cat sprite.





























                 Step 3:   Add a new backdrop to the stage, Arctic.

                 Step 4:   Now drag the ask block to the script area. Click on the block. A speech bubble appears
                         above the penguin with the text, “What’s your name?”.





                                                                                              Scratch Programming  61
   58   59   60   61   62   63   64   65   66   67   68