This add-on video will show you how to make the ball sprite react to being hit by theathlete. You can make it do something fun, like change colors, or something funny, likesay “ouch!” You’ll use another conditional to completethis. Select the ball sprite, and drag out an “if” block. The ball sprite will checkif it’s being hit – which means it’s touching the athlete. Find the “touching”block in “sensing,” and drag it into the condition space. Select “Player1” fromthe dropdown menu. Next, put the ball sprite’s reaction insidethe conditional. You can create any type of reaction. The sprite might change colors orsay something, or the background could change. Browse around in the “Motion” and “Looks”menus to find something cool for your sprite to do.
The example will show the sprite making a sound when it’s hit. To add a sound to yourproject, click the “Sounds” tab, then under “New Sound,” click “Choose soundfrom library.” The example will use “Ya.” Click it, click “OK,” then go back to“Scripts.” To add the sound to the conditional, go to“Sound,” and place the “play sound until done” block inside the “if” block. Addmore blocks in here if you’d like your project to play different sounds!
If you click this new stack and the ball sprite isn’t touching the athlete sprite, it won’t do anything.
Drag the ball on top of the athlete sprite, and click again.
Sweet! It makes a noise.
Okay, two more things. First, this new stackneeds to run at the same time as the other stack. Drag out another “when flag clicked”event, and snap it on top of your new code stack.
Try running this code now. It doesn’t work. That’s because when the flag is clicked,the code immediately checks to see if the sprites are touching, and if they aren’t,it stops and doesn’t check again. To fix this, use a loop. Add a “forever”loop just like you did in the first stack. That way, the new stack runs for as long asthe old one does. All right, Here’s the game plan:Choose a fun action for your sprite to perform when it hits the athlete.
Make a new stack for the ball sprite with “when flag clicked,” “forever,” “if,”and “touching” blocks. Place the new actions inside the “if”block. Test your code, and look back at this videoif you need help figuring it out. Still stuck? Go ahead and ask your neighbors, Hosts, orGurus for help.
Choose an Add-On
Program the ball sprite to do or say something when it bounces.
Design your athlete to reflect your favorite team.