Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 128 - 2620_Birla Open Mind C-5
P. 128

    You can also use the forever and repeat blocks with these blocks.

                  Let us make a small script.

                    Change  the sprite to  butterfly and change the backdrop to

                  flowers.

                  The butterfly changes colour and size when it touches the colours
                  selected in the touch block.

                  Similarly, you can create scripts with two sprites, and they change

                  colour when they touch each other.

                       LOOPS

                  All the programs or projects developed till now ran only once. If you want to run a set of
                  statements more than once, you can either run the code again or write the script again. In

                  Scratch, we can save our time and effort by repeating the code without writing the program or
                  script again. The automatic running of a set of instructions more than once is called looping.
                  The blocks for looping are given in Control category.
                                                                                                               repeat  10
                  The Repeat block is used to run a set of instructions for a specified number of

                  times.
                                                                                                           repeat  until
                  The Repeat until block is used to run a set of instructions till a condition is
                  satisfied.

                  The Forever block is used to run a set of instructions continuously until stopped.           forever

                  The instructions inside this block will be executed in a loop until the Stop button
                       is clicked by the user.

                      126  Premium Edition-V

| 123 124 125 126 127 128 129 130 131 132 133 |