Page 138 - Scratch Programming Playground
P. 138

Make the Paddle Flash When Hit


                         In this step, you’ll make the paddle flash different colors when
                         it is hit by the ball. add the following code to the Paddle sprite.
















                             The bounce message is broadcast when the Tennis Ball
                         sprite bounces off a Brick clone and when it bounces off the
                         Paddle sprite. The if distance to Tennis Ball < 60 block
                         makes the color changes happen when the Tennis Ball sprite
                         bounces off the Paddle sprite (which means the ball will be
                         less than 60 steps away).





                         save Point


                         Click the green flag to test the code so far. make sure the
                         paddle flashes different colors when the ball bounces off it.
                         Then click the red stop sign and save your program.





                         Add an Animated Entrance and Exit to the Bricks

                         The Brick clones’ entrance to the game is rather boring.
                         They just appear as soon as they’re cloned. To animate their
                         entrance, modify the Brick sprite’s code to match this code.












      112   ChapTer 5
   133   134   135   136   137   138   139   140   141   142   143