Page 83 - Learn To Program With Scratch
P. 83

Start by opening the file Fireworks_NoCode.sb2, which contains the initial
                          setup of the application without any scripts. As shown in Figure 3-17, the
                          application contains two sprites: the City sprite and the Rocket sprite. The
                          City sprite shows an image of tall buildings that you can animate in any way
                          you like. The Rocket sprite will continuously create clones that explode in
                          the dark sky, producing the fireworks.
                             The Rocket sprite has the eight costumes shown in Figure 3-18. The first
                          costume, C1, is just a small dot that we’ll launch into the sky. When this dot
                          reaches its destination, which is selected at random, it will switch to one of
                          the other costumes (also at random) to simulate the initial explosion. We’ll
                          then use an appropriate graphic effect to make this explosion look more
                          realistic.


















                          Figure 3-18: The eight costumes of the Rocket sprite .


                             With this plan in mind, add the script shown in Figure 3-19 to the Rocket
                          sprite. The script runs when the user clicks the green flag. After hiding the
                          Rocket sprite, it starts a forever loop to create clones of itself at random times.
                          Since the clones inherit the visibility state of the Rocket sprite, all created
                          clones will be hidden at first.












                          Figure 3-19: The first script of the Rocket
                          sprite

                             We now need to tell the cloned rockets what to do. This script is shown
                          in Figure 3-20.





                                                                                Looks and Sound   61

                                           www.it-ebooks.info
   78   79   80   81   82   83   84   85   86   87   88