Page 90 - 2502_Pakistan-kifayat_C-8
P. 90

Differences Between Repeat, Forever, and Repeat Until

              The following table summarises the differences between the different types of loop blocks in Scratch:

                      Block                      Description                                   Use

                                    Repeats a set number of times.           When you know exactly how many times
                                                                             to repeat.





                                    Repeats continuously without             When actions need to run endlessly.
                                    stopping.






                                    Repeats until a specific condition is    specific condition is true.
                                    true.







              Combining Different Types of Loops

              Combining different types of loops means using more than one kind of loop in a script. For example, you
              might use a repeat until block to perform an action until a condition becomes true, such as touching
              the edge using the touching edge? sensing block, and a forever block to keep running another task

              continuously. Using different types of loops together helps your script work more efficiently and perform
              multiple actions at the same time.

              To move a sprite until it touches the edge while continuously changing colours, use the following script:


































                  88  Premium Edition-VIII
   85   86   87   88   89   90   91   92   93   94   95