Please update your browser
Your browser version is not supported by this site. CS First may not work properly.
This add-on video will show you
how to make the ball sprite react
to being hit by the athlete.
You can make it do something fun, like change colors,
or something funny, like say "Ouch."
You'll use another conditional to complete this.
Select the ball sprite and drag out an If block.
The ball sprite will check if it's being hit,
which means it's touching the athlete.
Find the Touching block in Sensing
and drag it into the Conditions space.
Select Player One from the drop-down menu.
Next, put the ball sprite's reaction inside the conditional.
You can create any type of reaction.
The sprite might change colors or say 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 your project, click the Sounds tab.
Then click the Choose Sound From Library.
The example will use "Yeah."
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.
Add more blocks in here if you would 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 stack needs to run
at the same time as the other stack.
Drag out another One Flag Clicked event
and snap it on top of your new code stack.
Try running the 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 touch again.
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 as the old one does.
Alright, here's the game plan.
Choose a fun action for your sprite
to perform when it hits the athlete.
Next, 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 video
if you need help figuring it out.
Go ahead and ask your neighbors for help.