Discuss Scratch

JohnnyRock199
Scratcher
26 posts

Make clones move while off-screen?

Hello all! I have a project in which I am trying to make clones (of the “pedestrian” sprite) move on their own while off-screen. I was able to make a scrolling background that moves when the player moves, and I can do this for the pedestrians but I'd like to know how I can make them autonomously change how far off the screen they are. Can anyone help?
axisjack
Scratcher
100+ posts

Make clones move while off-screen?

Not sure i understand but maybe you can use the hide block when player sprite is off screen
codeman1044
Scratcher
500+ posts

Make clones move while off-screen?

axisjack wrote:

Not sure i understand but maybe you can use the hide block when player sprite is off screen
The question is how to make the position of the pedestrians change while they are off screen, not how to make them go off screen.

I would recommend using scripts that wait a random amount of time and then change the variable that you're using to store the pedestrians' positions.

Let me know if you need an example or a better explanation.

This is my signature, which shows up every time I post (this is for people who are confused)
I'm kind of… (for lack of a better word) addicted… to helping on the forums… should I be concerned?
Somehow, I missed my 500th post and can't remember when it happened… lol.
If you see (DATA MISCODED) then I just removed something. If I'm feeling silly, then you might see (OWO). Or both. That might happen too. (DATA MISCODED OWO)
#Shamelessplugs:
My first big project! https://scratch.mit.edu/projects/280489344/
My second account's first big project! https://scratch.mit.edu/projects/298640492/
My studio! https://scratch.mit.edu/studios/8064104/
axisjack
Scratcher
100+ posts

Make clones move while off-screen?

codeman1044 wrote:

axisjack wrote:

Not sure i understand but maybe you can use the hide block when player sprite is off screen
The question is how to make the position of the pedestrians change while they are off screen, not how to make them go off screen.

I would recommend using scripts that wait a random amount of time and then change the variable that you're using to store the pedestrians' positions.

Let me know if you need an example or a better explanation.

I see well in that case hide and then use random number to set a new position?
deck26
Scratcher
1000+ posts

Make clones move while off-screen?

You need things to move in real world coordinates. You only decide whether they're on screen or not by applying scrollx/y as an adjustment to give the screen coordinates.

forever
change realx/y
set screenx/y to realx/y plus/minus scrollx/y (depends how you're using your scroll variables)
show/hide according to screenx/y
end
098765432154321
Scratcher
100+ posts

Make clones move while off-screen?

deck26 wrote:

You need things to move in real world coordinates. You only decide whether they're on screen or not by applying scrollx/y as an adjustment to give the screen coordinates.

forever
change realx/y
set screenx/y to realx/y plus/minus scrollx/y (depends how you're using your scroll variables)
show/hide according to screenx/y
end

You forgot to do the scratchblocks tag.

forever
change [realx/y v] by (???)
set [screenx/y v] to ((realx/y) - (scrollx/y)) // depends how you're using your scroll variables
hide
end

deck26
Scratcher
1000+ posts

Make clones move while off-screen?

098765432154321 wrote:

deck26 wrote:

You need things to move in real world coordinates. You only decide whether they're on screen or not by applying scrollx/y as an adjustment to give the screen coordinates.

forever
change realx/y
set screenx/y to realx/y plus/minus scrollx/y (depends how you're using your scroll variables)
show/hide according to screenx/y
end

You forgot to do the scratchblocks tag.

forever
change [realx/y v] by (???)
set [screenx/y v] to ((realx/y) - (scrollx/y)) // depends how you're using your scroll variables
hide
end
No, I was showing pseudo-code.
JohnnyRock199
Scratcher
26 posts

Make clones move while off-screen?

098765432154321 wrote:

deck26 wrote:

You need things to move in real world coordinates. You only decide whether they're on screen or not by applying scrollx/y as an adjustment to give the screen coordinates.

forever
change realx/y
set screenx/y to realx/y plus/minus scrollx/y (depends how you're using your scroll variables)
show/hide according to screenx/y
end

You forgot to do the scratchblocks tag.

forever
change [realx/y v] by (???)
set [screenx/y v] to ((realx/y) - (scrollx/y)) // depends how you're using your scroll variables
hide
end

Thank you for this. I have now successfully created a sprite that randomly and autonomously moves (A.K.A. an NPC), even while not on the screen. Thanks to all who have helped!

Last edited by JohnnyRock199 (May 24, 2019 23:53:29)

Powered by DjangoBB

Standard | Mobile