private void ParseColliderLayer(Scene scene) { // create render target var target = new RenderTarget2D(Scene.GraphicsDevice, _map.Width * _map.TileWidth, _map.Height * _map.TileHeight); var anyvisible = false; // for each layer... foreach (var i in _map.Layers) { if (i.Visible) { // if it properly contained "tileset" key if (i.Properties.ContainsKey("Tileset")) { // Add by the index of i(the tmxlayer), tilesheet loading the Tileset property and the tileset id _tilesets.Add(_map.Layers.IndexOf(i), new TileSheet( scene.Pipeline.LoadContent <Texture2D>(i.Properties["Tileset"], scene.Content), Convert.ToInt32(i.Properties["ID"]))); if (i.Name.Contains("Collision Layer")) { anyvisible = true; Scene.GraphicsDevice.SetRenderTarget(target); Scene.GraphicsDevice.Clear(Color.Transparent); Scene.SpriteBatch.Begin(SpriteSortMode.FrontToBack, BlendState.NonPremultiplied, SamplerState.PointClamp); DrawLayer(Scene.SpriteBatch, i, true); Scene.SpriteBatch.End(); } } } } if (anyvisible) { Terrain = target.ConvertToBody(scene); } target.Dispose(); Scene.GraphicsDevice.SetRenderTarget(null); }