(resolved) How do I sort sprites by their Y-position?

Get help using Construct 2

Post » Mon Dec 29, 2014 8:29 pm

Hi

I'm trying out a prototype (see attached screenshot) where I have a whole bunch of sprites in a fake "depth". I'm trying to find a way to sort all of these objects so that they render from top to bottom, so that all things high up on the screen will render first (on the bottom) and gradually all other items are drawn on top of previous sprites.

How do I do this?

In an earlier stage I only had one moving character, which was a lot easier since I could compare that character's Y-position to all other elements (if their Y > Player Y then I would move them to a layer below, conversely I'd move things in front to a layer on top of the player)

Now that I'm introducing multiple moving elements I don't know how to formulate a function that does this. I think it should all hapen on one single layer and that I probably need to do this sorting every tick, but IDK.. I'm guessing I need a loop of some sort, but how do I write it?

Hope this makes sense, any help would be awesome :)
You do not have the required permissions to view the files attached to this post.
Last edited by drutten on Mon Dec 29, 2014 9:59 pm, edited 1 time in total.
B
8
S
2
Posts: 28
Reputation: 546

Post » Mon Dec 29, 2014 8:50 pm

Watch "about isometric" (construct 2 General) from me.
Playable games:
http://jamesxxxyz.newgrounds.com/
Newest: Blue and red arrows
Latest update: Blue and red arrows

What you want in C3?
viewtopic.php?f=146&t=122050

Youtube: https://www.youtube.com/channel/UCLE7Ml ... /playlists
B
11
S
4
Posts: 281
Reputation: 1,543

Post » Mon Dec 29, 2014 9:59 pm

Awesome! Thanks.

This did the trick for me:

Image

(link to the post)
https://www.scirra.com/forum/about-isometric_t120594
B
8
S
2
Posts: 28
Reputation: 546


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, irina, Yahoo [Bot] and 25 guests