Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » how to make it so the lower the sprites y, the higher their layer
- Sketfstudios
-
Scratcher
36 posts
how to make it so the lower the sprites y, the higher their layer
Side scroller
Enemies go up and down screen (and left and right)
I need them to layer, in order, based on their y height

LIKE THIS!!!!
i cant seem to figure it out! (but I have figured out size changing)
Enemies go up and down screen (and left and right)
I need them to layer, in order, based on their y height
LIKE THIS!!!!
i cant seem to figure it out! (but I have figured out size changing)
- 10data10
-
Scratcher
100+ posts
how to make it so the lower the sprites y, the higher their layer
You might try making the highest sprites go to the front first, followed by the next highest set of sprites and so on.
The stage could have:

and the sprites would have:

So the sprites with the highest Y value will end up at the back.
if 10 is too big of range then you could make it smaller and you might only need to broadcast layer adjustment when a sprite actually moved up or down.
The stage could have:

and the sprites would have:

So the sprites with the highest Y value will end up at the back.
if 10 is too big of range then you could make it smaller and you might only need to broadcast layer adjustment when a sprite actually moved up or down.
- Creatality
-
Scratcher
32 posts
how to make it so the lower the sprites y, the higher their layer
Why not this?
go back (y position) layers
Last edited by Creatality (April 2, 2023 23:53:46)
- MasterofTheBrick
-
Scratcher
1000+ posts
how to make it so the lower the sprites y, the higher their layer
Why not this?Concept is there, but the total number of layers in place will depend on the number of existing sprites and clones in your project. Your code wouldn’t be effective since the sprite would be sent immediately to the backmost layer (if the project had 5 sprites and the lowest was was situated at y=180, going back 180 layers would be the opposite of what the OP intends to achieve).go back (y position) layers
- Creatality
-
Scratcher
32 posts
how to make it so the lower the sprites y, the higher their layer
Oh okWhy not this?Concept is there, but the total number of layers in place will depend on the number of existing sprites and clones in your project. Your code wouldn’t be effective since the sprite would be sent immediately to the backmost layer (if the project had 5 sprites and the lowest was was situated at y=180, going back 180 layers would be the opposite of what the OP intends to achieve).go back (y position) layers
- Discussion Forums
- » Help with Scripts
-
» how to make it so the lower the sprites y, the higher their layer



