Page 105 - 2422_C5_Flipbook
P. 105

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.
                 Step 2:   Insert a sprite, Penguin2 on the
                          stage. Delete the cat sprite.

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

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

                            You will also see an input box on the stage with a blinking cursor. You will notice that
                          the input box waits for your input. Once you type it, your name will appear in the box.
                          When you click the tick button or press Enter, the name will disappear.

                 Step 5:   To display the typed name also, click on the check box before the answer block. The
                          answer appears on the stage.







                                                             4




                                5



                                                                                                     3







                 You can also place the answer block in the say block. It will look something like this.








                                                                                       Conditional Blocks in Scratch  103
   100   101   102   103   104   105   106   107   108   109   110