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 Potenza e velocità

Transcript

In this add-on, you'll add a feature to your project that lets the user adjust the passing power and the speed of the receivers to make the ball sprite and the receiver sprites move faster or slower. You will use variables with slider controls to complete this add-on.

Select the ball sprite to start. The value space in the “move” block contains the number that determines how fast the ball moves. It contains the number 10, so each time the loop runs the sprite moves 10 steps. To vary this number, use a variable! Go to data, and click "make a variable." Computers store changing information in variables. Name the variable "power," and click "OK." This added a bunch of new blocks for you to use. Drag the "power" variable block out, and snap it into the “move” block.

Next, to change the variable with a slider, check the box next to the variable in data.

The variable will appear on stage, but just as a number. Double click it one or two times until a slider appears. Test it out now. Move the slider, then hit the spacebar. Move it again, pass again. Isn't that neat? The slider changes the speed of the ball sprite. Okay, next you'll do the same with the receivers.

In "data," click "Make a Variable" again, and name this one "speed." Click "OK" to make this new variable. Then, for each of your receiver sprites, drag the new variable into the "move" block at the beginning of the "forever" loop.

Show the "speed" variable by checking its box, then double-click it on the stage until it becomes a slider. Great. Test again. Click the flag, and adjust the new slider to see the receivers speed up and slow down. That might be a little *too* fast.

Here's the game plan: Create new variables called "power" and "speed." Place them into the correct "move" blocks.

Then, create a slider that lets the user adjust the power and speed.

Scegli un’estensione
Gioco infinito
Fai scomparire e ricomparire gli attaccanti ogni volta che passi loro la palla.
Passa indietro
La palla ritornerà sempre nella sua posizione iniziale.
Potenza e velocità
Aggiungi delle variabili realistiche con cursori che permettono di controllare la velocità della palla e degli sprite Attaccante.
Segnapunti
Conta quanti passaggi riesci a completare.
Passa la palla
Modifica l'aspetto dello sprite Palla.
Esultare
Fai dialogare gli attaccanti.
arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Guarda il video di introduzione.
  2. Scorri verso il basso per visualizzare i componenti aggiuntivi scelti.
  3. Seleziona un componente aggiuntivo e inizia a creare!
  4. Scegli un altro componente aggiuntivo e continua a costruire.