private void DrawParallaxLayer(SpriteBatch sb, Layer layer) { // var samplerstate = layer.IsSeamless ? SamplerState.PointWrap : SamplerState.PointClamp; sb.Begin(SpriteSortMode.FrontToBack, null, SamplerState.AnisotropicWrap, null, null, null, _camera.GetViewMatrix(layer.Parallax)); var wh = new Vector2(_viewport.Width, 0); wh = _camera.ScreenToWorld(wh, layer.Parallax); var spr = layer.Sprite; var rect = layer.IsSeamless ? new Rectangle((int) (-spr.Position.X), 0, (int) wh.X, spr.Texture.Height) : spr.SourceRect; sb.Draw(spr.Texture, spr.Position, rect, spr.Color, spr.Rotation, spr.Origin, spr.Scale, spr.Effects, GetLayerSortOrder(layer.Order)); sb.End(); }
public void Add(Layer layer) { _layers.Add(layer); _layers.Sort((a, b) => a.Order.CompareTo(b.Order)); }