Skip to content

Please update your browser

Your browser version is not supported by this site. CS First may not work properly. Learn more

1. Parallax Introduction


Hey and welcome to Activity 4 of Google CS First Animation!

In this activity, you will build a parallax scrolling animation while you learn about the important computer science concept: local versus global variables.

Parallax describes the effect in which things that are closer appear to move faster than things that are farther away.

Animators imitate parallax with an awesome effect called “parallax scrolling.”

In parallax scrolling, objects closer to the front are animated to move faster than objects farther away.

This effect is used in games, and even websites!

It gives the illusion of depth in a side scrolling animation, and makes viewers feel like they're part of a three-dimensional world.

To build your parallax project, you'll create local, rather than global, variables.

Global variables are "for all sprites," and local variables are “for this sprite only.”

The global option is selected by default when you create a variable in Scratch.

If a sprite needs its own variable, or if each clone of a sprite needs its own private copy of a variable, you use a local variable.

Today, you’ll create clones that each use their own local variable.

For example, in this Scratch game, “global jump” is a global variable.

All sprites in the project share this variable.

This code says, when the left arrow key is pressed, glide up and down the number of steps in the global jump variable.

When the left arrow key is pressed, all sprites jump the same amount.

“Local jump” is a local variable.

Each sprite in this project has its own local jump variable.

When the right arrow key is pressed, each sprite moves up the value in their own local jump variable.

In this activity, you'll use a local variable to control how far away each object appears in the scene.

To start: Click the starter project link, click “remix,” and sign in to Scratch.

Then, return to CS First to watch the next video.

Next arrow_forward
  1. Click the starter project link.
  2. Click remix.
  3. Sign in to Scratch.