Discuss Scratch

Roblox_Player22
Scratcher
12 posts

How do you make a sprite scroll, like a scrolling frame type?

I need help with making a simple code that scrolls clones when you press the Up/down arrow.

I don't know what more info to give.

Thanks, Roblox_Player22
MrKingofScratch
Scratcher
100+ posts

How do you make a sprite scroll, like a scrolling frame type?

I'm not sure what you want. can you try explaining it in a different way?

my two guesses are that you want to change the character a player is controlling, or that you're trying to make all of the clones move at once and “scroll” across the screen.

is there a project you've found that does this that you can provide a link to?

what kind of game are you making?

Last edited by MrKingofScratch (March 9, 2024 22:40:27)

Roblox_Player22
Scratcher
12 posts

How do you make a sprite scroll, like a scrolling frame type?

MrKingofScratch wrote:

I'm not sure what you want. can you try explaining it in a different way?

my two guesses are that you want to change the character a player is controlling, or that you're trying to make all of the clones move at once and “scroll” across the screen.

is there a project you've found that does this that you can provide a link to?

what kind of game are you making?

I'm trying to make clones “scroll” on the Y axis, like when you scroll on a website. Here is a project: https://scratch.mit.edu/projects/852115178/

But I want to use clones instead.

I'm making a drawing-type game, with save slots. And you can have multiple slots, so scrolling is very convenient if you can say it like that.

Last edited by Roblox_Player22 (March 9, 2024 22:47:04)

MrKingofScratch
Scratcher
100+ posts

How do you make a sprite scroll, like a scrolling frame type?

ok this will require a variable to keep track of how far down you've scrolled in the form of a y coordinate. for this example, i'll use
scrolly
to reset this variable each time the project is started (so that you always start at the top), we can add the code
whenclickedsetscrollto0
Now, we can make it so that when you press the down arrow, it increases this number, because the down arrow will make you scroll further down the page.
whendown arrowkeypressedchangescrollby10
we can do the opposite for the up arrow, since it should scroll up instead of down.
whenup arrowkeypressedchangescrollby-10
Now, we can set the clone's Y position, or how far up or down the screen the clone is, based on this value.
whenIstartasacloneforevergotox:0y:scroll

however, this will set all of the clones at the same position. to fix this, we need to give each clone an “offset” when they're created. for example, a clone further down the page would have a greater offset than one closer to the top.

we can do this in the clone creation script. I imagine yours will look something like this:
whenclickedrepeatputtheamountofclonesyouwillhaveherecreatecloneofmyselfnextcostume
we can make each clone spawn with a different offset by using another variable. Lets call this one
cloneoffset
*IMPORTANT* make sure that when you're making the variable, you check the “for this sprite only” box. this will make it so that each clone will have a seperate “copy” of this variable. Don't worry about it if it doesn't make sense, just know that it makes it so that each clone can have a different number for that variable.
If you want the space between each clone to be 100 pixels, you can change the code above to this code:
whenclickedsetclone offsetto0repeatputtheamountofclonesyouwillhaveherecreatecloneofmyselfnextcostumechangeclone offsetby100
feel free to change the “100” value if you want the clones to be spaced closer together or further apart.
finally, we can modify the “when i start as clone” script to use the clone offset variable.
whenIstartasacloneforevergotox:0y:scroll+cloneoffset

If there are any issues let me know. also, to make sure that the clones can go fully offscreen, draw a big invisable box around each costume in the costume editor (if you need help with this let me know).

I hope this helps!

Last edited by MrKingofScratch (March 9, 2024 23:11:49)

Roblox_Player22
Scratcher
12 posts

How do you make a sprite scroll, like a scrolling frame type?

MrKingofScratch wrote:

ok this will require a variable to keep track of how far down you've scrolled. for this example, i'll use
scrolly
so

Ah, I see!

Thanks!
MrKingofScratch
Scratcher
100+ posts

How do you make a sprite scroll, like a scrolling frame type?

Let me know if there are any issues
Roblox_Player22
Scratcher
12 posts

How do you make a sprite scroll, like a scrolling frame type?

MrKingofScratch wrote:

Let me know if there are any issues

That's exactly what I needed! Thank you so much

Have an amazing Day/Night!
MrKingofScratch
Scratcher
100+ posts

How do you make a sprite scroll, like a scrolling frame type?

I'm glad I could help

Powered by DjangoBB