Discuss Scratch

_Floof_
Scratcher
9 posts

x and y scroller

How do you make a scroller that scrolls both sideways and upwards?

Extra question:
Can you make it only scroll upwards when you reach a specific height?

Sincerely _Floof_
deck26
Scratcher
1000+ posts

x and y scroller

The technique is the same, you just need scrollX and scrollY variables and each non-player sprite needs to know its real world position (scrollX/Y are just adjustments to the real world coordinates to decide if the item is visible in the current window).

Only scrolling when y is above a certain value is relatively trivial - either adjust y or scrollY according to the situation.
_Floof_
Scratcher
9 posts

x and y scroller

deck26 wrote:

The technique is the same, you just need scrollX and scrollY variables and each non-player sprite needs to know its real world position (scrollX/Y are just adjustments to the real world coordinates to decide if the item is visible in the current window).

Only scrolling when y is above a certain value is relatively trivial - either adjust y or scrollY according to the situation.
Thank you very much

I tested it and the sprites end up on the edge of the screen if the player moves around in the “starting” sprite, do I have to make a border or something like that?
A solution would be greatly appreciated.
Link:
https://scratch.mit.edu/projects/199035693/
(don't mind the pictures)
deck26
Scratcher
1000+ posts

x and y scroller

_Floof_ wrote:

deck26 wrote:

The technique is the same, you just need scrollX and scrollY variables and each non-player sprite needs to know its real world position (scrollX/Y are just adjustments to the real world coordinates to decide if the item is visible in the current window).

Only scrolling when y is above a certain value is relatively trivial - either adjust y or scrollY according to the situation.
Thank you very much

I tested it and the sprites end up on the edge of the screen if the player moves around in the “starting” sprite, do I have to make a border or something like that?
A solution would be greatly appreciated.
Link:
https://scratch.mit.edu/projects/199035693/
(don't mind the pictures)
Scratch doesn't like sprites going completely off screen so a border can help hide sprites. Otherwise you have to hide them yourself when their ‘world’ coordinate mean they're outside (or close enough) the visible area.
DerpyHead0
Scratcher
1000+ posts

x and y scroller

Actually, there's a trick to make a sprite go off the edge.

switchcostumetoHuge boxMoveswitchcostumetoNormal costume

For the huge box costume, make it in vector mode, and drag the edges of the box past the edges of the canvas. it doesn't need to be ridiculous, it just needs to not be too close to the edges

Powered by DjangoBB