public void Draw(SpriteBatch spriteBatch, Rectangle area, CameraManager camera) { area.Inflate(1, 1); //area not fully inside camera view, cut of the rest if (!camera.DrawArea.Contains(area)) { DrawInformation drawInformation = new DrawInformation(area, camera); spriteBatch.Draw(Texture, drawInformation.DrawLocation, drawInformation.TexturePart, Color.White); return; } spriteBatch.Draw(Texture, area, Color.White); }
public void Draw(SpriteBatch spriteBatch, Rectangle area, CameraManager camera) { area.Inflate(1, 1); int width = Texture.Width / Columns; int height = Texture.Height / Rows; int row = (int)((float)CurrentFrame / (float)Columns); int column = (int)CurrentFrame % Columns; //the full frame to display relative to the texture Rectangle sourceRectangle = new Rectangle(width * column, height * row, width, height); DrawInformation drawInformation = new DrawInformation(area, camera, sourceRectangle); spriteBatch.Draw(Texture, drawInformation.DrawLocation, drawInformation.TexturePart, Color.White); Update(); }