Please note: This theme has not been updated to reflect Scratch 3.0. Visit this help article for more info.
Transcript

In this add-on, you will program music to fade in and out during your project.

To start, add a music loop to your project.

Then drag out a play sound until done block into the script editor, and add a forever loop around this block.

Add a one flag click block to the top of the stack.

Test it.

(upbeat music)

Awesome.

The music should start relatively low or quiet, then get louder.

Drag out a set volume block from the Sound menu and place it under the one flag clicked block.

Tinker with the value to set the volume of the music at the start of the project.

This example uses 4%.

Awesome.

Next, add a change volume block.

Use a positive number to make the volume increase gradually.

A smaller number will make the music fade in more slowly.

This example uses 0.5.

The volume should get louder until it reaches a certain point.

So add a repeat until block around the change volume block.

Next, place a greater than operator in the condition field.

Put a volume block from the Sound menu in the first blank.

The code now reads, change the volume by 0.5 until the volume is greater than a certain number.

This example uses 80% in the greater than operator.

Next, tell the music when to fade in.

Add a broadcast block to the top of the code stack that animates the Android.

Name the message something that makes sense.

This example uses, music fade in.

Great.

Then add a when I receive message block to the repeat until block.

Test this.

(upbeat music)

Awesome.

To program the music to fade back out, duplicate the fading in code stack.

Switch the greater than operator to a less than operator, and change the value to a small number to set the minimum volume.

This example uses four.

Next, edit the change volume block to a negative number.

This example uses negative 0.5.

Great, now, tell the music when to fade out.

Drag a broadcast block somewhere near the end of the animation code, and name the message something that makes sense, like, music fade out.

Then change the dropdown menu on the when I receive block to the name of your message.

Now, the music fades in, plays throughout the story, then fades out.

(upbeat music)

Now, it's your turn.

Program a song to play forever during your story.

Program the music to fade in and out.

Cue the music to fade in and out using broadcast and when I receive blocks.

Choose an Add-On

Sunrise, Sunset

Program a sunrise or sunset for your story.

Weather

Program objects to fall from the sky.

Music Fade

Add background music which fades in and out.

Slow Motion

Add a slow motion effect to your android.

Draw

Use the drawing tools to add your own animation.

User Input

Interact with the user of your program.

Instructions

  1. Choose an add-on, and click the "Watch" button to learn how to build it.
  2. After you finish, come back to the add-ons Screen to try another add-on!