Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // I have a Tile[] called tiles
- // I loop through all of the tiles
- foreach (Tile tile in tiles)
- {
- // Skip null tiles
- if (tile == null) continue;
- // Get the texture
- Texture2D texture = tile.GetTexture(Content);
- // Render it using the Batcher from RenderableComponent's Graphics object
- graphics.batcher.draw(
- texture,
- transform.position + new Vector2(tilePosition.X * TileSize, tilePosition.Y * TileSize),
- texture.Bounds,
- Color.White,
- 0,
- Vector2.Zero,
- 1,
- SpriteEffects.None,
- // FOR SOME REASON THIS DEPTHLAYER IS IGNORED
- tile.Layer.GetFloatValue()
- );
- }
- // 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.
- // Regardless of what the depthLayer values are, it will always go in order of the for loop (order of draw calls).
- // So is depthLayer useless?
- // 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."
- // Thanks!
Advertisement
Add Comment
Please, Sign In to add comment