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 Add Mystery with a Pulsing Object

Transcript

In this video, you will make the object in your story pulse.

This will add a fun animation when your characters discover the unusual object.

To start, click the object sprite.

Click the code tab, and select the Looks menu.

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

Click the block to see how it works.

With each click, the sprite gets larger.

Now add code to make the object get smaller.

Drag out another “change size by” block from the Looks menu, but don’t attach it to the first “change size by” block.

Change the value to negative 10.

Click the block.

Nice!

Each click makes the sprite get smaller.

If you click these blocks repeatedly, the sprite looks like it’s pulsing.

You can program the computer to run these blocks in order.

Attach the blocks, and click to test.

Nothing happens!

The computer runs these blocks so quickly, you can’t see the sprite move.

To fix this, program the computer to wait between each action.

Select the Control menu, and add a “wait” block between the two “change size by” blocks.

Click to try it out.

Great!

The sprite gets bigger, then shrinks.

To repeat this action to make the object continuously pulse, use a repeat loop.

Select the “Control” menu, and drag out a “repeat” block.

It fits around other code blocks and makes the blocks inside it run multiple times.

Place it around the block stack, and click to run.

The sprite pulses, but the animation doesn’t look smooth.

When the code repeats, the “change size by” block runs, then the next “change size by “ block runs right away.

To fix this, add another “wait” block after the second “change size by” block.

Click to run it.

Nice!

To change how the sprite pulses, tinker with the values in the “change size by” and “wait” blocks.

You can make your object pulse faster or slower to add action or drama that fits your story.

To reset the size of your object, change the size value on the stage.

Add a “when flag clicked” event to make this animation happen at the beginning of the program.

Test your code.

When you click the flag to start your program, the object pulses.

Great job!

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

Now that your object is pulsing, use “say” blocks for your character sprites so they can respond to the animation.

Now, it’s your turn!

Select the object sprite, and add two “change size by” blocks to create a pulsing effect.

To make the sprite grow and shrink, change the value in one change size by block to a negative number.

Add wait blocks to make the animation visible and smooth.

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 make the animation go along with 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.