Page 51 - 2501_KVS_C-5
P. 51

Aryan: Ok, thanks dear. I have understood, how to create and destroy clones of
                                    the sprites, as per our requirement. But what are these “hide” and “show” blocks
                                    in Figure (5.2 and 5.4)? Please explain this also.

                                    Gowri: Sure.

                 5.2 SHOW AND HIDE BLOCKS— “LOOKS” BLOCK

                 5.2.1 “show” block
                 This is a “stack” block used to show the sprite, when it is required.

                 5.2.2 “hide” block
                 This is a “stack” block used to hide the sprite, when it is required.


                 5.3 RECEIVE AND BROADCAST MESSAGES— “EVENTS” BLOCK
                 5.3.1 “when I receive…” block

                 This block is a “hat” block used to do some specific task when the sprite receives the
                 message, sent by same sprite or any other sprite.

                 5.3.2 “broadcast…” block
                 This  block  is  a  “stack”  block  used  to  broadcast
                 or  send  the  particular  message.  This  block  has

                 a  dropdown  list,  from  where  you  can  choose  a
                 message  name  or  can  also  create  a  new  message
                 and give a name for message as per your choice.
                 (see figure 5.5)
                                                                                              Fig. 5.5
                 5.3.3 “broadcast… and wait” block

                 This block is a “stack” block used to broadcast or send a particular message either
                 an existing one or a new message, and then wait until all scripts triggered by that
                 message have finished running before continuing.

                                      Gowri: So, in previous coding (figure 5.2 and 5.4), the sprite “planet” is hidden
                                      when “flag” is clicked means when game is started, it is not showing instantly
                                      and same with the missile. It will appear when clone of this sprite is created.



                     Aryan: Ok, dear Gowri, I have understood it now. Then what is the need to learn
                     this concept of broadcast and receive message? Could you teach me this block in
                     detail as well?


                     Gowri: Yes dear, Sure! When there is a situation, where a sprite is hidden and we need to show
                     it from another sprite’s script or code, we cannot show this sprite directly. Instead, we need
                     to broadcast a message, and then show the sprite when it receives that message. Let’s learn
                     this concept with the help of an activity.



                                                                                      Scratch                       49
   46   47   48   49   50   51   52   53   54   55   56