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 Code a Color Change

Transcript

In this video, you will program the object in your story to change colors.

This will help you make your story more exciting or mysterious by changing the object in a way that surprises your characters and the audience.

To start, select the object sprite.

Program the sprite to change colors.

Click the code tab, and select the Looks menu.

Click, hold, and drag out a “change color effect by” block.

Click the block to see what it does.

Cool!

Each click changes the color of the object.

To make this happen more than once without having to keep clicking the block, use a loop.

A loop is a block that repeats the actions inside it.

Select the control menu, and drag a “repeat” loop around the “change effect” block.

Click the stack to test it.

The colors change, creating a fun rainbow effect.

Finally, program the block to run when the flag is clicked.

Select the events menu, and a place a “when flag clicked” block at the top of the stack.

Test your code.

When you click the flag to start your program, the object changes colors when the character sprite speaks.

Nice.

Tinker with the values in the repeat loop to make the change color effect happen longer.

Or, tinker with the values in the “change effect by” block to change how the colors look.

To reset the color of your object, click the stop button.

To make this animation go along with your dialogue, add a "wait" block under the "when flag clicked" event.

Now that your object is changing colors, use “say” blocks for your character sprites so that they can interact with the exciting and mysterious object.

Now, it’s your turn!

Create a multicolor effect by selecting the object sprite, and using the “change effect by” block.

Add a “repeat” loop to run the code multiple times.

Add a “when flag clicked” block to the top of the block stack to start your code at the beginning of your program.

Finally, add a “wait” block under the “when flag clicked” event to match the animation to the dialogue.

Then, return to this page to select another video to try.

Choose an Add-On
Start here
Continue the Conversation
Add code to both character sprites to continue their conversation.
Code a Color Change
Make the object change colors.
Add Mystery with a Pulsing Object
Make the object grow and shrink repeatedly to look like a pulse.
Add Sounds to Your Story
Add sound to the story when the characters discover the unusual object.
Make Your Object Bounce
Code the object to bounce around the screen.
Paint Your Own Animation
Use the costume editor in Scratch to customize an animation.
Animate a Story Title
Build a title card for the project and animate it before the story begins.
Let the Audience Decide
Ask the audience a question and make something happen based on the response.
Add an Object
Add another object to the story to create more action.
Instructions

Para hacer esta actividad en español, haz clic aquí.

Students
  1. Watch the introduction video.
  2. Open an 'adventure' project link below and add characters and dialogue.
  3. Return to this page and watch more videos below.
Teachers
  1. Visit the Hour of Code teacher resource page for instructions.