Page 49 - 2501_KVS_C-5
P. 49

Step 2:   Choose the background “Galaxy” from “Choose a backdrop” icon.  Next,
                             we will learn, how to create the clones of the sprite “planet” and sprite
                             “missile” (as shown in figure 5.1.2).


                 5.1 CLONE OF THE SPRITE— “CONTROL” BLOCK
                 5.1.1 “create clone of ….” block

                 This block is a “stack” block used to create a clone of the selected sprite from the
                 list provided in the block. It creates an identical copy of the chosen sprite: however,
                 its scripts are not copied.

                 5.1.2  “delete this clone” block
                 This block is a “cap” block (a block that ends the script). It is used to delete a clone

                 or copy of the sprite that has already been created.
                 5.1.3  “when I start as a clone” block

                 This is a “hat” block (a block that starts the script). It is used to perform the tasks
                 written under it when a clone of the sprite is created.





                     Gowri: Steps to create and delete the clone of the sprite “planet” and “missile”.



                 Step 3:   Choose the sprite “planets” and drag and drop the block “when flag click”
                             in  script  area.  In  “forever”  block  after  every  2.5  seconds,  a  clone  of
                             “planets” sprite is creating. (see figure 5.2)



                     Aryan: Ok, that’s so simple dear. Now, how can we delete this
                     clone?


                     Gowri: Yes, as per game criteria, when a planet is hit by a missile,
                     its clone gets finished. See the code in figure (5.3):




                 Step 4:   Now choose the sprite “missile” and drag & drop
                             the  block  “when  flag  clicks”  in  the  script  area.
                             Next  do  the  coding  in  “forever”  block.  Inside

                             the “if () then” block, insert “when space key is
                             pressed” condition, followed by the “create clone                      Fig. 5.2
                             of myself” block to create a clone of missile sprite. (see figure 5.4). Create
                             another script for the same sprite starting with “when I start as a clone”
                             block. When the sprite “missile” touches the edge of the stage, then it

                             gets deleted. This code is shown in figure 5.4 in “repeat until” block.


                                                                                      Scratch                       47
   44   45   46   47   48   49   50   51   52   53   54