Advertisement
Masadow

Haxeflixel depth sorting idea

Mar 4th, 2014
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 0.48 KB | None | 0 0
  1. var _objects : Array<FlxObject>();
  2.  
  3.  
  4.  
  5. public function draw()
  6. {
  7.     var objects = sortObjects(); //Sort every single objects by depth, should return a sorted copy of _objects
  8.     var topObject = objects.pop(); //Pop out the top drawn object
  9.  
  10.     //Loop through tiles
  11.     for (tile in tiles)
  12.     {
  13.         //Check if the object should be drawn before the tile
  14.         while (topObject != null && isDrawnBefore(topObject, tile))
  15.         {
  16.             draw(topObject);
  17.             topObject = objects.pop();
  18.         }
  19.         draw(tile);
  20.     }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement