Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How do I make a scrolling background?
- royalguard006
-
29 posts
How do I make a scrolling background?
For my game photon-shot I have decided to make a scrolling background because the game is starting to feel cramped how would I go about this?
The game:https://scratch.mit.edu/projects/880660062
The game:https://scratch.mit.edu/projects/880660062
- NMario84
-
1000+ posts
How do I make a scrolling background?
https://en.scratch-wiki.info/wiki/Scrolling_(sprites)
Since you can't change the X Y of the background itself, you make the background a sprite object.
Basically, set X position of background sprite to Variable + (480 * 0). Then add or subtract the variable depending which way you want it to move.
Since you can't change the X Y of the background itself, you make the background a sprite object.
Basically, set X position of background sprite to Variable + (480 * 0). Then add or subtract the variable depending which way you want it to move.
- DylTLip
-
35 posts
How do I make a scrolling background?
https://en.scratch-wiki.info/wiki/Scrolling_(sprites)
Since you can't change the X Y of the background itself, you make the background a sprite object.
Basically, set X position of background sprite to Variable + (480 * 0). Then add or subtract the variable depending which way you want it to move.
So using something like this above? if so, why do you do 480 * 0? That would just = 0; are you supposed to change this value to something?
- NMario84
-
1000+ posts
How do I make a scrolling background?
480 is the width of the canvas. So each new background you want to scroll would be 480*1, 480*2, 480*3, 480 *4, etc.
480*0 would indeed output 0, therefore the background would remain at 0,0, which is your starting point. 480*1 would output 480. Since it is positive value, it would be placed 480 pixels to the right of the canvas until you change the value of your variable to make it scroll the other way.
If you want to scroll it upwards/downwards, you would want to use 360 for Y position in place of 480. The Scratch screen window is 480x360.
480*0 would indeed output 0, therefore the background would remain at 0,0, which is your starting point. 480*1 would output 480. Since it is positive value, it would be placed 480 pixels to the right of the canvas until you change the value of your variable to make it scroll the other way.
If you want to scroll it upwards/downwards, you would want to use 360 for Y position in place of 480. The Scratch screen window is 480x360.
Last edited by NMario84 (Aug. 30, 2023 20:40:12)
- DylTLip
-
35 posts
How do I make a scrolling background?
480 is the width of the canvas. So each new background you want to scroll would be 480*1, 480*2, 480*3, 480 *4, etc.
480*0 would indeed output 0, therefore the background would remain at 0,0, which is your starting point. 480*1 would output 480. Since it is positive value, it would be placed 480 pixels to the right of the canvas until you change the value of your variable to make it scroll the other way.
If you want to scroll it upwards/downwards, you would want to use 360 for Y position in place of 480. The Scratch screen window is 480x360.
Ohhhh so this is using clones to create the background? I have never seen this method for creating a scrolling background before. I might borrow that.
- NMario84
-
1000+ posts
How do I make a scrolling background?
Yea. This is assuming we're using clones here.
You could “probably” do it with vector images without too much cloning, but I imagine it would be a lot harder. If the vector image exceeds the field of view somehow, you would then have to get the size of that vector image, use that value if you need to scroll another vector image against the original.
Though I try not to use vector images in my own projects anyway. It's just a preference of presentation, I guess. Maybe vector images are better depending what kind of project you want to make, though you would have to consider the loading times, and the size of the images for that case.
You could “probably” do it with vector images without too much cloning, but I imagine it would be a lot harder. If the vector image exceeds the field of view somehow, you would then have to get the size of that vector image, use that value if you need to scroll another vector image against the original.
Though I try not to use vector images in my own projects anyway. It's just a preference of presentation, I guess. Maybe vector images are better depending what kind of project you want to make, though you would have to consider the loading times, and the size of the images for that case.
- DylTLip
-
35 posts
How do I make a scrolling background?
I shall take this into consideration in future projects. Looks like I learned something from this post too! Yea. This is assuming we're using clones here.
You could “probably” do it with vector images without too much cloning, but I imagine it would be a lot harder. If the vector image exceeds the field of view somehow, you would then have to get the size of that vector image, use that value if you need to scroll another vector image against the original.
Though I try not to use vector images in my own projects anyway. It's just a preference of presentation, I guess. Maybe vector images are better depending what kind of project you want to make, though you would have to consider the loading times, and the size of the images for that case.
- EnchantingRoserade
-
100+ posts
How do I make a scrolling background?
Try this for backdrops. (its object lol)
- Discussion Forums
- » Help with Scripts
-
» How do I make a scrolling background?