Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a scrolling background?
- EBowald17
-
New Scratcher
1 post
How do I make a scrolling background?
I would be overjoyed if someone can clear up a few things for me, I don't understand how to make backgrounds scroll, I'm wanting to make a background scroll left-right if that's possible, I've seen some people pull it off, but I don't know how to do it myself 

- Dragonite905
-
Scratcher
54 posts
How do I make a scrolling background?
If you want to try making a side scrolling game, the first thing you do is create your background with individual sprites. Every object in the background needs to have its own sprite. Then, when you begin writing code for moving, instead of the player (or whatever the “camera” follows) moving, everything in the background moves. It is also important to note that when sprites touch the edge of the stage, they stop moving and clump up together. One way to fix this is by making a variable:
These scripts also only allow sprites to move when they are shown (Volume is a variable used for each individual sprite; I used it to avoid making new variables for each sprite. As long as you only play music on a separate sprite or the backdrop, you should be fine). I hope this helps!
when green flag clickedThe idea of this is so that with background sprites when they reach the edge they disappear, and when they need to show up again, they reappear.
set [x v] to [0]
forever
if <key [left v] pressed?> then
change [x v] by (10)
end
if <key [right v] pressed?> then
change [x v] by (-10)
end
when green flag clicked
forever
if <<(x) < [240]> and <(x) > [-240]>> then
show
set volume to (100) %
else
hide
set volume to (0) %
end
end
when green flag clicked
forever
if <(volume) = [100]> then
if <key [left v] pressed?> then
change x by (10)
end
if <key [right v] pressed?> then
change x by (-10)
end
end
end
These scripts also only allow sprites to move when they are shown (Volume is a variable used for each individual sprite; I used it to avoid making new variables for each sprite. As long as you only play music on a separate sprite or the backdrop, you should be fine). I hope this helps!

- Little-Sophie
-
Scratcher
1 post
How do I make a scrolling background?
…..,…..,…..,…..,…..,…..,…..,…..,…..,…..,
- -Snipet-
-
Scratcher
500+ posts
How do I make a scrolling background?
Griffpatch has a few good tutorials on this.
- StrangeMagic32
-
Scratcher
1000+ posts
How do I make a scrolling background?
This may help a little…
https://scratch.mit.edu/projects/290908771/
https://scratch.mit.edu/projects/290908771/
- rain1wing
-
Scratcher
1 post
How do I make a scrolling background?
how do you make it scroll every where. l
- codeman1044
-
Scratcher
1000+ posts
How do I make a scrolling background?
Please don't necropost. If you need help then please make your own topic.
- MoneyProject
-
Scratcher
11 posts
How do I make a scrolling background?
I don't know what I'm doing with big text, but what I think he means is how to make a scrolling backdrop.
- cbar1434
-
New Scratcher
1 post
How do I make a scrolling background?
I made a bunch of background sprites,, but my player sprite s behind them
- imfh
-
Scratcher
1000+ posts
How do I make a scrolling background?
I made a bunch of background sprites,, but my player sprite s behind themPlease check the date before posting; this topic is from 2017.
To make the player sprite go in front of the other sprites, try using this block:
go to [front v] layer :: looks
- Discussion Forums
- » Help with Scripts
-
» How do I make a scrolling background?