Scrolling in Scratch is the action of sliding sprites across the Stage. Scrolling in Scratch typically involves using a set of sprites and moving them across the stage while having no gaps between sprites. Common uses of scrolling in Scratch include platformers, scrolling text, maps in adventure games, and sometimes large pictures. Having an object(s) scroll across the stage is commonly seen in Scratch projects. In the Scratch community, knowing how to produce a scrolling effect is a highly valued ability; there is a common misconception that producing such an effect is very difficult. A project that uses scrolling is often referred to as a scroller.

## How to Scroll

Scrolling is produced by creating scripts that move the sprite or set or sprites across the screen. Usually, Scratch users want to make an image greater than the stage bounds (480 by 360) scroll which proves difficult because Scratch restricts the size of sprites to the stage bounds. Many methods of producing scrolling involve creating a series of sprites each being the size of the stage bounds.

### Scrolling Without Reusing Sprites

This is the most commonly used method of scrolling for beginners. It is sometimes referred to as the "Traditional Method" because it is usually the first method most users try as well as being featured in one of Scratch's sample projects. This uses one sprite per 480x360 tile of scrollable area. This method involves multiple sprites. To create a 2 way scrollable area a script like this is needed:

```when flag clicked
forever
go to x: ((scrollX) + ((480) * (0))) y: (0)
```

A sprite with this script will appear in position number 0. 480 is the the amount of space between sprites, the number it is multiplied by determines its position in a set of sprites, and the scrollX variable lets the user control the movement (in this case on the x-axis) for the set of sprites.

```when flag clicked
forever
go to x: ((scrollX) + ((480) * (1))) y: (0)
```

Each time a sprite is added it must be manually given a new position number. Placing the following script would place a sprite in position 1 and make it appear beside the sprite with the above script.

Due to the way Scratch keeps sprites from going outside the stage area, a script like this may be desired to prevent overlapping sprites:

```when flag clicked
forever
if <([abs v] of (x position)) > [480]>
hide
else
show
end
```

The number 480 can be replaced with something else depending on the width of screen that you want the sprites to scroll across.

To solve the issue of overlapping sprites some prefer to include a black border around their screen in which case this script is not necessary.

You will also need some way of changing the variable, so that the set of sprites can be moved by the user. A script like this one is fine.

```when flag clicked
forever
if <key [right arrow v] pressed?>
change [scrollX v] by (-10)
end
if <key [left arrow v] pressed?>
change [scrollX v] by (10)
end
```

#### X and Y Scrolling

This is exactly the same as the "Traditional Method", except you can scroll upwards, as well as across. You will need more scripts just like the ones above except with a different variable, and you will have to replace the number 480 with the height of the area you want to scroll in (typically 360).

### Two Player Scrolling

Two Player Scrolling is typically split screen scrolling. When using this method, one player's character is on the top of the screen and one on the bottom. The players use different controls, but their characters are in the same landscape with the same backgrounds. To begin you will need to make the background sprites. Afterwards duplicate them for the second player. You need two variables; a scroll variable for player 1 and a scroll variable for player two. You will need to duplicate player one and player two so that they can go be seen on both sides of the split screen.

After your costumes have been created, insert this script or a similar script in Player 1's script area:

```when flag clicked
set [Player 1 ScrollX v] to [0]
forever
if <key [right arrow v] pressed?>
change [Player 1 ScrollX v] by (-10)
end
if <key [left arrow v] pressed?>
change [Player 1 ScrollX v] by (10)
end
```

However, this script will vary depending on the color of the stage and other elements.

Then duplicate the script seen before and insert it into Player 2's script area. You will need to change the variable used and the arrow keys pressed.

In the duplicate of player one's script area (the sprite that will appear in the other half of the split screen) copy this script:

```when flag clicked
go to x: ((Player 2 ScrollX) - (Player 1 ScrollX)) y: (([y position v] of [Player 1 v]) - (anything))
if <<((Player 2 ScrollX) - (Player 1 Scrollx)) > [240]> or <((Player 2 ScrollX) - (Player 1 ScrollX)) < [-240]>>
hide
else
show
end
end
```

Put exactly the same script on the duplicate of player 2 except with (y position of player 2) rather than (y position of player 1).

For player 1's terrain use exactly the same method as the Traditional Method except use your variable for player 1's scrolling. The same goes for player 2 except with player 2's scrolling variable.

## 1 Sprite 1 Script method

1S1S scrolling is advanced and scrolls only using 1 sprite. File:1s1s scrolling.gif

The old y variable must change the same amount as Y position when Jumping .

More information can be found here: One Sprite One Script Project

## Top Down Scrolling

Top down scrolling is scrolling that you view from the top. Some examples by Nintendo are older versions of Mario Kart (or the bottom screen of the game on any DS device) and older versions Zelda (or DS/Gameboy Zelda games).

An example Scratch project is Mario Kart by Lucario621.

Instructions can be found on Scrolling Background.

## Scrolling With Reusing Sprites

This method of scrolling reuses the scrolling object by stamping it at one position, switching to the next costume, and stamping again at another scrolling position. Repeat this process until you achieve the desired scrolling distance.