How do I Sort the Z Axis by the Y co-ordinate?

0 favourites
  • 4 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • I have had this question answered before a year ago but the link that was put in the answer has no expired.

    I also want to expand on this by no only sorting sprites order in a layer but also a tilemap. Is that possible?

    Thanks

  • I had done this before, but with sprites only (I didn't use tilemap on my project at that time).

    You can do like this:

    for each [object] order by [object].Y descending {
    	[object] move to top of layer
    }[/code:gmbonft5]
  • Thanks, I don't think it will work for a tilemap though as they can't be in the same family as a sprite

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • How about storing all related object's UID in an array, sort them, then pick one by one and set it to top?

    Probably 2 dimensional array, y(0) = Y coordinate; y(1) = object type ("sprite"/"tilemap"); y(2): UID. This way, you can sort by X axis and get the sort by Y coordinate.

    first store each UID in array;
    sort array by X axis;
    for each array x element {
    	if( array.at(array.curX, 1) == "SPRITE") {
    		pick [sprite object] with UID = array.at(array.curX, 2);
    		move object to top of layer;
    	} else {
    		pick [tilemap object] with UID = array.at(array.curX, 2);
    		move object to top of layer;
    	}
    }[/code:zpdjcf18]
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)