Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

arrow_back Reazione al rimbalzo


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 condition space. Select “Player1” from the dropdown 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 under “New Sound,” click “Choose sound from 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. Add more 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 stack needs 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 as the 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 video if you need help figuring it out. Still stuck? Go ahead and ask your neighbors, Hosts, or Gurus for help.

Scegli un’estensione
Reazione al rimbalzo
Ordina allo sprite Palla di fare o dire qualcosa quando rimbalza.
La maglia della squadra
Fai indossare all'atleta la maglia della tua squadra del cuore.
Secondo giocatore
Aggiungi un altro atleta per creare una partita a due.
Aggiungi un segnapunti al gioco.
Sfida il computer
Programma uno sprite che giochi contro l'utente.
Rimbalzo casuale
Fai rimbalzare la palla in una direzione a caso
arrow_backward Indietro
Avanti arrow_forward
  1. Scegli un componente aggiuntivo e fai clic su "Guarda" per scoprire come costruirlo.
  2. Una volta terminato un componente aggiuntivo, scegline un altro da provare!