layers-Libgdx

is there any way to render sprites on different layers (no parallax) int libgdx? I’ve been searching for a way but I can’t seem to find anything. any help would be great!

sorry for the short question
[Edit] ps. I know that rendering order determines what renders on top of what. I just want to know if there is an easier way to do it
pss. what i mean by “rendering order” is the order in the code

I don’t think so, but you just have to add a “height” value to your sprite and sort it.

You can set a z-index and use a comparator.
something like so:


Comparator<Integer> comp = new Comparator<Integer>(){
    @Override
    public int compare(int o1, int o2){
        return new Integer(o1.x).compareTo(o2.x);
    }
};

Collections.sort(list, comp);

I asked the same thing on the libgdx forum and was also told to use a sorted list. It works fine even with my 500+ sprites to sort

okay now what if i had 2 different lists? how would I sort it then?

Make a third list.

It depends on the values you use. You could use bucket or bubblesort.
If max(list1)<=min(list2) or vise versa you could sort them without putting them together.