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 Seleziona il colore

Transcript

Note that this add-on works best when sprites are a single color.

To begin, click the pattern maker sprite, then the costumes menu.

An easy way to create different-colored costumes is to duplicate a costume and fill it with different colors. To accomplish this, right click a costume, then click “duplicate.” Click the duplicated costume, select a different color you like, then click the "color a shape" icon. Now, click the parts of the image you want to fill with a new color.

You can repeat this process a couple of times. It's tempting to create costumes that are every color of the rainbow, but for now limit yourself to four different costumes. You can always go back and add more costumes later, but right now you want to leave enough time to finish coding your project.

Rename each of the costumes to reflect their colors. In this example, the costumes are named blue, red, yellow, and black.

Next, add a sprite that will ask the user what color the pattern should be. If you completed the Pattern Project Introduction add-on, you might have already added a sprite that could ask this question. If not, click the "add sprite from library" icon, and select a sprite.

Next, add an "ask" block from the sensing menu. In the field, ask what color the user wants the sprite to be and specify which colors are available.

To change the sprite's costume based on the user’s answer, create a conditional statement.

Under the “ask” block, add an “if-then” block. Then, place an "equals" block from the operator menu in the “if” portion of the “if-then” block. Next, add an "answer" block to one side of the "equals" block. On the other side, enter the color of one of the costumes.

Next, place a "broadcast" block in the "then" portion of the "if-then" block. From the dropdown menu of the “broadcast” block, select "new message," and call the message the same name as the color.

In this example, the code says: If the user's answer equals red, then broadcast the message “red.”

Now, switch to the "pattern maker" sprite. This step is really important because this sprite is the one you will program next.

Drag out the "when I receive" block, and select the message you just created from the dropdown menu.

Duplicate the code below the "when 1 key pressed" block, and add it to the bottom of this code stack.

In the switch costume block, choose the correct color costume from the dropdown menu.

Now, the user is able to choose one color.

Each time you broadcast a message for a color, make sure the correct color costume is selected. Finally, select the sprite that will ask the user which color pattern they want to see. Add an event that triggers the sprite to ask this question. In this example, the sprite asks the question when the green flag is clicked.

But, you can use another event, like “when this sprite clicked” or “when space key pressed.”

Scegli un’estensione
Benvenuti nel mio progetto
Programma uno sprite per presentare il tuo progetto.
Seleziona il colore
Permetti all'utente di scegliere il colore del modello.
Modelli alternati (Sfida)
Crea un modello alternato unico.
La colonna sonora (Sfida)
Aggiungi una musica di sottofondo al tuo progetto.
Nuovi tessuti
Aggiungi altri tessuti al tuo modellista.
Il titolo
Aggiungi un titolo al vostro progetto.
arrow_backward Indietro
Avanti arrow_forward
Istruzioni
  1. Scegli un componente aggiuntivo e fai clic su "Guarda" per imparare come personalizzare il tuo progetto.
  2. Quando hai terminato, torna sulla schermata dei componenti aggiuntivi e prova un altro componente aggiuntivo!