Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Need Help - How to make scrolling background
- glam0003
-
2 posts
Need Help - How to make scrolling background
Hey guys i am stuck on how to make my background scroll vertical (Top-down) without the picture looking unusual. This is the script i am using for the background sprite:
When up arrow key pressed
point in direction 180
move 2 steps
when down arrow key pressed
point in direction 0
move 2 steps
Please help!!!! thanks
When up arrow key pressed
point in direction 180
move 2 steps
when down arrow key pressed
point in direction 0
move 2 steps
Please help!!!! thanks
- andre_rifaut
-
100+ posts
Need Help - How to make scrolling background
There are tutorials and simple projects explaining that.
Just in the “search” area at the middle top put the three words
scrolling background tutorial
I found this http://scratch.mit.edu/projects/10171686/
and this http://scratch.mit.edu/projects/2096276/
Just in the “search” area at the middle top put the three words
scrolling background tutorial
I found this http://scratch.mit.edu/projects/10171686/
and this http://scratch.mit.edu/projects/2096276/
- Lone-Wolf
-
87 posts
Need Help - How to make scrolling background
I was going to help you, but my mom called me out to do chores, and I have to leave.
So I'll have to finish my little “tutorial” for you when I get back, or tommorow. So sorry! 


- Lone-Wolf
-
87 posts
Need Help - How to make scrolling background
Okay, okay, I'm back! 
Well, to scroll you need tons of variables, operators, movement, etc. and if you're a beginner, it's quite complicated. I have a project that is simply a scrolling test, and you can see the inside to see how it works. I'll tell you how anyways, to go along.
You will need a variable called Scroll Y for vertical, and a variable called Scroll X for horizontal. (I'm just explaining Scroll X, but Scroll Y is basically the same thing. Just Y's instead of X's)
The way these work is that when you press a particular button, it changes the variable by a certain amount, or you could just make it scroll automatically. (The bigger the amount the faster the speed) The Scratch screen consists of 480 pixels, so to make the backgrounds match up, you use this number in your script.
So if you're doing this based on arrows being pressed, it'll work this way. (If not, then just change the script and make it run in a loop automatically) When the right key is pressed, make it change Scroll X by -5. (Or a different amount if you want it faster or slower) And when you press the left key, make it change scroll X by 5.
Next for the first background, make it's X position constantly (with the forever block) go to Scroll X + 480 * 0. Now, dur, 480 times zero equals zero, but this makes it easier in the script to simply duplicate. So then duplicate this “Forever set X position to Scroll X + 480 * 0” and put it in your second background sprite, but instead of 480 * 0, set it to 480 * 1. Then continue doing the same thing with any other sprites you may have, increasing the Scroll X + 480 *… plus one more than the last.
I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/
P.S. If you need an example program for automatically scrolling backgrounds, I'd be glad to make one for you!

Well, to scroll you need tons of variables, operators, movement, etc. and if you're a beginner, it's quite complicated. I have a project that is simply a scrolling test, and you can see the inside to see how it works. I'll tell you how anyways, to go along.
You will need a variable called Scroll Y for vertical, and a variable called Scroll X for horizontal. (I'm just explaining Scroll X, but Scroll Y is basically the same thing. Just Y's instead of X's)
The way these work is that when you press a particular button, it changes the variable by a certain amount, or you could just make it scroll automatically. (The bigger the amount the faster the speed) The Scratch screen consists of 480 pixels, so to make the backgrounds match up, you use this number in your script.
So if you're doing this based on arrows being pressed, it'll work this way. (If not, then just change the script and make it run in a loop automatically) When the right key is pressed, make it change Scroll X by -5. (Or a different amount if you want it faster or slower) And when you press the left key, make it change scroll X by 5.
Next for the first background, make it's X position constantly (with the forever block) go to Scroll X + 480 * 0. Now, dur, 480 times zero equals zero, but this makes it easier in the script to simply duplicate. So then duplicate this “Forever set X position to Scroll X + 480 * 0” and put it in your second background sprite, but instead of 480 * 0, set it to 480 * 1. Then continue doing the same thing with any other sprites you may have, increasing the Scroll X + 480 *… plus one more than the last.
I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/
P.S. If you need an example program for automatically scrolling backgrounds, I'd be glad to make one for you!

Last edited by Lone-Wolf (May 16, 2013 23:49:03)
- dracae
-
1000+ posts
Need Help - How to make scrolling background
I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/ My Scrolling Project
Fixed!

(EDIT: You fixed it? Ok. Should I delete this?)
Last edited by dracae (May 16, 2013 23:51:15)
- Lone-Wolf
-
87 posts
Need Help - How to make scrolling background
Fixed!
What? I already fixed it… That was weird. You must have edited it while I was.

- glam0003
-
2 posts
Need Help - How to make scrolling background
I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/ My Scrolling Project
Fixed!
(EDIT: You fixed it? Ok. Should I delete this?)
Thanks for the help but its not quite working

- Lone-Wolf
-
87 posts
Need Help - How to make scrolling background
I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/ My Scrolling Project
Fixed!
(EDIT: You fixed it? Ok. Should I delete this?)
Thanks for the help but its not quite working
Oh, no no, the project was always fine, my hyperlink just got messed up, so I had to edit it to fix it.

- Lone-Wolf
-
87 posts
Need Help - How to make scrolling background
Thanks for the help but its not quite working
What are you trying to accomplish? An automatically scrolling background, one that moves as you do, or what? Because I'd LOVE to help you do this, but I don't see what isn't working.
Last edited by Lone-Wolf (May 18, 2013 20:00:13)
- Dragonturnip
-
36 posts
Need Help - How to make scrolling background
I know a REALLY simple way to scroll, check out my two latest projects.
- typemaster
-
100+ posts
Need Help - How to make scrolling background
This post is about how to scroll side to side. The guy does not move, but it looks like it.
Script for the guy you want to “move”:
Script for the thing you want to scroll Note: Must be a sprite, not the stage.
I hope this helped you!
Here is a link to my project that scrolls: http://scratch.mit.edu/projects/24268768/
Script for the guy you want to “move”:
Script for the thing you want to scroll Note: Must be a sprite, not the stage.
I hope this helped you!
Here is a link to my project that scrolls: http://scratch.mit.edu/projects/24268768/
Last edited by typemaster (July 3, 2014 02:42:16)
- typemaster
-
100+ posts
Need Help - How to make scrolling background
Try the post that I did before this one and tell me if that worked.I hope this helped! Here's my program to help you! You can use the script if you want, or simply for reference. Here's the URL:
http://scratch.mit.edu/projects/10160196/ My Scrolling Project
Fixed!
(EDIT: You fixed it? Ok. Should I delete this?)
Thanks for the help but its not quite working
- Discussion Forums
- » Help with Scripts
-
» Need Help - How to make scrolling background