Discuss Scratch

BrandonEpixYT
Scratcher
11 posts

Sprites moving together

I have one sprite that acts as the backdrop but moves left and right based on the mouses x position. There is a door that can be opened and closes with the w key. How can I get the door to stay over the gap while the other sprite moves
-ShadowOfTheFuture-
Scratcher
1000+ posts

Sprites moving together

It's a bit hard to tell exactly what you want here without any context. Can you share the project and provide a link so we can better know how to help you?

<Insert uncreative signature here>









██       ██  ██            ██  ██       ██
██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██
███ ███ ██ ████ ██ ███ ███
█████████ █████ █████ █████████

“Though the seasons come and go, and sunshine turns to snow, we will always have tomorrow up ahead.”
-ShadowOfThePast-
Scratcher
100+ posts

Sprites moving together

I think I've fixed it: https://scratch.mit.edu/projects/261463221/ (I remixed it)

Basically, the problem was that you were setting the “scroll X” to the background sprite's x position, and then having the code for its x position to change. The door's position was being set to “scroll X + 100”, where “scroll X” was the background sprite's old x, when the background sprite had already moved. That caused the lag.

In addition to that, I've also helped get rid of some redundant “when green flag clicked” blocks and forever loops.

Hope I helped!










Hello.
imfh
Scratcher
1000+ posts

Sprites moving together

Check out this tutorial by @TheLogFather. You might also want to see part 2 which shows how to do it with multiple sprites.

Last edited by imfh (Nov. 12, 2018 14:56:25)


Scratch to Pygame converter: https://scratch.mit.edu/discuss/topic/600562/

Powered by DjangoBB