Page 83 - Trackpad_V1_Book 5_Flipbook
P. 83

We have already learned how to change the costume of a sprite and to work with two
                 sprites in the previous class. Now, in this chapter, we will learn to create variables and
                 control the movement of the sprite in a better manner.




                          VARIABLES IN SCRATCH

                 Variables are used to hold information such as a word or a number. Variable is a named
                 location where you can store information. We can create variables for one or for all the
                 sprites.


                 GLOBAL VARIABLES
                 If a variable is created, to be used and modified by all the sprites, then it is known as

                 a global variable. A global variable can be created on any sprite but its value can be
                 accessed or modified by other sprites used in the project.

                 LOCAL VARIABLES

                 Local variables can only be accessed or modified from the sprite where it was created.

                 CREATING A VARIABLE

                  To create a variable, follow the given steps:

                                                                     4  Select whether the
                                                                    block is ‘For all sprites’ or
                                                                    ‘For this sprite only’.





                                                                                                   3   Type a name
                                          2  Click on Make                                        in Variable name
                                         a variable.                                              box.







                                                         5  Click on OK button.
                    1  Click on the Data Block.






                      Tick ( ) if you know this.
                      ▶    Variables are a named location where you can store information.

                      ▶    We can create our own variables in Scratch.






                                                                                                  More on Scratch  81
   78   79   80   81   82   83   84   85   86   87   88