0

so I'am currently working with the game (using libgdx) and I want to make that objects(textures) from arraylist WorldObjects which has lowest float z; to draw(render).So I need to make that game would render from lowest to highest float z;

example: 8, 8, 5, 2, 2, 2, 2, 1.4

ArrayList<WorldObject> worldObjects = new ArrayList<WorldObject>();

then this is world object class

public class WorldObject {
Texture texture;
float x, y, z;
public WorldObject(Texture texture, float x, float y, float z) {
    this.texture = texture;
    this.x = x;
    this.y = y;
    this.z = z;
}}
IgnasR
  • 172
  • 3
  • 10
  • what have you tried so far? Any code? Do you use Stage and Actors? Watching at the marble tells me you should Sort your textures in the renderlist and give them a Z index. – bemeyer Dec 23 '15 at 14:41
  • I haveArrayList worldObjects = new ArrayList(); which contains worldobject's and then i cant figure out what to do so that worldobject with lowest float Z; would draw first – IgnasR Dec 23 '15 at 14:42
  • show us the renderingcode and the world objects else we can just guess. Moreover sorting a ArrayList is preaty simple and already asked several times. – bemeyer Dec 23 '15 at 14:42
  • Possible duplicate of [How to sort an ArrayList in Java](http://stackoverflow.com/questions/18441846/how-to-sort-an-arraylist-in-java) Simply change the comperator to a z order comperator. – bemeyer Dec 23 '15 at 14:43
  • how can I sort an arraylist ? – IgnasR Dec 23 '15 at 15:04
  • http://stackoverflow.com/questions/18441846/how-to-sort-an-arraylist-in-java as already tagt. – bemeyer Dec 23 '15 at 15:04

0 Answers0