Discuss Scratch

the_extreme_coder
Scratcher
93 posts

I'm trying to make it so that things that are lower on the Y axis go in front of things that are higher on the Y axis

How would I do this?
deck26
Scratcher
1000+ posts

I'm trying to make it so that things that are lower on the Y axis go in front of things that are higher on the Y axis

Easiest method is to make a broadcast which makes each object wait until a variable is lower than the objects y-position and then it goes to the front. Then run a loop to set the variable to 180 and step it down to -180 - steps of 5 or 10 may be OK rather than stepping 1 at a time. Add a wait 0 seconds and repeat if necessary.

Depends a bit on how much things are changing though. If only one or two objects are changing their layer there will be better ways to do this.
beniwal577
Scratcher
16 posts

I'm trying to make it so that things that are lower on the Y axis go in front of things that are higher on the Y axis

Here maybe try this:
foreverifyposition<0thengoback10layerselsegotofront
Put this in each sprite you are using.

Last edited by beniwal577 (Oct. 17, 2021 15:09:47)

orangetheory
Scratcher
500+ posts

I'm trying to make it so that things that are lower on the Y axis go in front of things that are higher on the Y axis

We can make 2* global variables, and set them to the y position of the sprite. Then, we can use an if statement to check every single frame whether or not one sprite is higher than the other.
*two is for demonstration purposes. Make as many variables as there are sprites/clones.
Kind of like this:

in sprite 1whenclickedforeversetsprite 1 y postoyposition in sprite 2whenclickedforeversetsprite 2 y postoyposition in sprite 1whenclickedforeverifsprite1ypos>sprite2yposthengotofront in sprite 2whenclickedforeverifsprite2ypos>sprite1yposthengotofront

Last edited by orangetheory (Oct. 17, 2021 15:11:54)

the_extreme_coder
Scratcher
93 posts

I'm trying to make it so that things that are lower on the Y axis go in front of things that are higher on the Y axis

Thank you everyone for the help!

Powered by DjangoBB