SHARE
TWEET

Untitled

a guest Feb 3rd, 2019 12 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // I have a Tile[] called tiles
  2. // I loop through all of the tiles
  3. foreach (Tile tile in tiles)
  4. {
  5.   // Skip null tiles
  6.   if (tile == null) continue;
  7.  
  8.   // Get the texture
  9.   Texture2D texture = tile.GetTexture(Content);
  10.  
  11.   // Render it using the Batcher from RenderableComponent's Graphics object    
  12.   graphics.batcher.draw(
  13.     texture,
  14.     transform.position + new Vector2(tilePosition.X * TileSize, tilePosition.Y * TileSize),
  15.     texture.Bounds,
  16.     Color.White,
  17.     0,
  18.     Vector2.Zero,
  19.     1,
  20.     SpriteEffects.None,
  21.     // FOR SOME REASON THIS DEPTHLAYER IS IGNORED
  22.     tile.Layer.GetFloatValue()
  23.   );
  24. }
  25.  
  26.  
  27. // For example, I have tried setting a Tile with a layer of 0.5, and another with a layer of 1, and it goes in order of the foreach loop rather than the layers' order.
  28. // Regardless of what the depthLayer values are, it will always go in order of the for loop (order of draw calls).
  29. // So is depthLayer useless?
  30.  
  31. // For now, I've resorted to sorting the array using the Layer value before looping, but it would be nice to have it working without this "hack."
  32. // Thanks!
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top