Skip to content

Please update your browser

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

4. Die Umfragewerte zurücksetzen

Transcript

In this video, you'll program the “clear votes” button to set all votes back to zero.

Select the "clear votes" sprite that was included in the starter project.

Click the "data" menu, and drag out the "set variable to 0" block. Change the value in the dropdown to match one of your variable names. If you click the block, you'll see the variable’s value change from the amount of votes registered to "0."

This only reset one value, so do the same steps for the other 3 values, choosing the appropriate variable name for each "set" block. Try it out. When you click the whole stack, all variables will be set to 0. A big part of computer science is persisting through tough problems. If the first solution you try doesn’t work, try again.

Next, connect this block stack to the "clear votes" button by clicking on the events menu and using a "when this sprite clicked" event to start the code. You can read the stack like a sentence now: "When this sprite clicked, set sneakers to 0, set high tops to 0, set panda to 0, and set penguin to 0." Try it out. When the "clear votes" button is clicked, all of the votes are set to 0. Perfect! As your last step today, share your project with the Scratch community so others can experience your creative work. Don’t forget to add a description and some tags. Now it's your turn. Select the "clear votes" sprite, add code to set each of the variables to 0 when the button sprite is clicked. When you are done with this step, ask a neighbor to take your fashion poll. Then, click the green arrow to choose some add-ons to customize your program.

arrow_backward Zurück
Weiter arrow_forward
Anweisungen
Setzt alle Variablen zurück auf 0, wenn die Schaltflächen-Figur angeklickt wird.