DrawObjectLayer() public method

Draws all objects on the given object layer
public DrawObjectLayer ( SpriteBatch spriteBatch, Int32 objectLayerID, Rectangle region, System.Single layerDepth ) : void
spriteBatch Microsoft.Xna.Framework.Graphics.SpriteBatch XNA SpriteBatch instance; SpriteBatch.Begin() must be called before using this method
objectLayerID System.Int32 Index of the layer to draw in the Map.ObjectLayers collection
region Microsoft.Xna.Framework.Rectangle Region of the map in pixels to draw
layerDepth System.Single LayerDepth value to pass to SpriteBatch
return void
Example #1
0
        private void DrawLayersInOrder(Map map, SpriteBatch spriteBatch, Rectangle viewport)
        {
            float layerDepth = 1.0f;
            float layerDepthDec = 1.0f / (float)map.LayerOrder.Length;

            foreach (var layer in map.LayerOrder)
            {
                switch (layer.LayerType)
                {
                    case LayerType.TileLayer:
                        map.DrawLayer(spriteBatch, layer.ID, viewport, layerDepth);
                        break;

                    case LayerType.ObjectLayer:
                        map.DrawObjectLayer(spriteBatch, layer.ID, viewport, layerDepth);
                        break;

                    case LayerType.ImageLayer:
                        map.DrawImageLayer(spriteBatch, layer.ID, viewport, layerDepth);
                        break;
                }

                layerDepth -= layerDepthDec;
            }
        }