Discuss Scratch

ProbablyScottWhat
Scratcher
7 posts

Scrolling background

I have set up a scrolling background for whenever left or right, keys are pressed but my character moves with the screen which I don't want. is there a way my character can go off the screen when they are not meant in the frame?
I feel like I didn't explain well so ill link the project: https://scratch.mit.edu/projects/729742491/

I don't want the character moving with the screen
GopherStudios
Scratcher
14 posts

Scrolling background

You could add an X and Y variable so the screen'd only move if the charicter moved to an area?

it'd probally end up working like this:


ifX/Ywenthigherthan_____thenstopsthingthatmakesyourgamescrollend

Last edited by GopherStudios (Sept. 8, 2022 21:55:08)

ProbablyScottWhat
Scratcher
7 posts

Scrolling background

How do i get the x/y went higher than. I still learning on scratch
Spentine
Scratcher
1000+ posts

Scrolling background

ifabsofxposition>240thensetxto480*xposition>0-240ifabsofyposition>180thensetyto360*yposition>0-180

This is if you don't want the character to go off the screen… I'm not sure what you mean when you don't want the player to get out of frame.

Last edited by Spentine (Sept. 8, 2022 22:58:39)

ProbablyScottWhat
Scratcher
7 posts

Scrolling background

Sorry i meant l want the character off screen when scroll x or y is not in its area
deck26
Scratcher
1000+ posts

Scrolling background

We need to pin down what you're asking here. Is this a standard scroller with the player fixed n the middle of the screen until they get close enough to the edge of their world in which case the scrolling stops and the player moves instead? But in that case i wouldn't expect the player to go off screen.

If that's not it what do you mean by the frame as opposed to the screen? Why do you have two separate loops telling the background to move - getting rid of the smaller script at least lets the background move?

Powered by DjangoBB