how to make a moving background in scratch

Scratch Tutorial: Create Animated Backgrounds Step-by-Step

By Joshua Young
AD

Interested in animating elements in Scratch? One impressive effect you can achieve is a moving background. This can bring life to your projects, enhancing the overall user experience. In this guide, we'll explore how to create a moving background in Scratch, optimizing your learning and mortar skills. Let's dive right in! Firstly, let's clarify what we mean by a moving background. A moving background, also known as a parallax effect, is when the background scrolls at a different speed than the main content, creating an illusion of depth and motion.

To begin, let's ensure you have Scratch 3.0 or later. While Scratch 2.0 is excellent for many projects, the newer version offers more features, and the UI is more intuitive. Now, let's get started on creating our moving background.

Setting Up Your Stage

Before creating the moving background, set your stage's backdrop to a sprite with a transparent color. This ensures your moving background effects will appear correctly. To do this:

AD
Let's Build: How to #code a Scrolling Background with #parallax #effect in #scratch - Part 2
Let's Build: How to #code a Scrolling Background with #parallax #effect in #scratch - Part 2
How to Make a Scrolling Background in Scratch | Tutorial
How to Make a Scrolling Background in Scratch | Tutorial
pink and white stars on a checkered background
pink and white stars on a checkered background

  1. Click on the Stage in the sprite list.
  2. Go to the 'Appearance' tab.
  3. Select 'Transparency' for the backdrop color.

an abstract black and white background with wavy lines
an abstract black and white background with wavy lines
an abstract white background with wrinkled paper
an abstract white background with wrinkled paper
an abstract black and white background with lines
an abstract black and white background with lines

Using Motion to Create Movement

Now, let's create a moving pattern for our background. For this example, we'll use the 'Motion' blocks and programmatically scroll the stage.

Try dragging a 'Motion' block and reducing 'speed' to create a subtle scroll. To randomize movement, use the 'change x position by' block within a 'when green flag clicked' block. This way, the stage scrolls smoothly and randomly.

AD

Changing Analysis to Enhance Effect

'Change' block with numbers can create jerky movements, making it less appealing. To achieve a smooth scroll, use the 'change x position by' block with random numbers.

a blue and black background with squares
a blue and black background with squares
an abstract black and white pattern with lines
an abstract black and white pattern with lines
Black Grid Motion background
Black Grid Motion background
bg (background )
bg (background )
an image of multicolored squares and rectangles that appear to be distorted
an image of multicolored squares and rectangles that appear to be distorted
an orange and yellow sunburst background with white lines in the center, as well as some light streaks
an orange and yellow sunburst background with white lines in the center, as well as some light streaks

To add randomness, use the 'pick value' block from the 'Operators' section, selecting 'list' and inputting the values you want your stage to move between.

Creating a Continuous Loop

After setting up the motion, you might notice your scene ends when it reaches the edge of the stage. To fix this, create a continuous loop.

AD

ALNST | R O U N D 3
ALNST | R O U N D 3
HOW TO MAKE A GIF INTO A BACKGROUND - How we made a BTS gif into a Google background that moves.
HOW TO MAKE A GIF INTO A BACKGROUND - How we made a BTS gif into a Google background that moves.
<3
<3

Setting Stage Width

Make your stage width larger than the size of your backdrop. This hides the fact that the backdrop is moving in a loop and gives it the illusion of continuous movement. To do this:

AD
  • Select 'Stage', then 'Appearance'.
  • Set 'Stage Width' to something larger than the size of your backdrop.

Resetting Stage Coordinates

Every time your backdrop reaches the edge, reset the stage's coordinates to continue the loop seamlessly. To do this:

  • Add a 'and' block to your 'when backdrop reaches edge' block.
  • Add 'set [x] position to' [0] and 'set [y] position to' [0].

Your moving background is now complete! You've created a looping, moving background that gives your Scratch project a dynamic and engaging look.

Mastering moving backgrounds in Scratch is a valuable skill that opens up a world of creative possibilities. Experiment with different colors, speeds, and patterns to create unique and captivating projects. Happy coding!

AD