using System; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; namespace MonoGame.Extended.Tilemaps { /// /// Represents a layer that displays a single image. /// public class ImageLayer : TilemapLayer { /// /// Gets or sets the image texture displayed by this layer. /// public Texture2D Texture { get; set; } /// /// Gets or sets the position of the image. /// public Vector2 Position { get; set; } /// /// Gets or sets a value indicating whether the image repeats horizontally. /// public bool RepeatX { get; set; } /// /// Gets or sets a value indicating whether the image repeats vertically. /// public bool RepeatY { get; set; } /// public override Rectangle Bounds { get { if (Texture == null) { return Rectangle.Empty; } // For repeating images, bounds are theoretically infinite // Return the base texture size at the layer's position return new Rectangle( (int)Position.X, (int)Position.Y, Texture.Width, Texture.Height ); } } /// /// Initializes a new instance of the class. /// /// The name of the layer. /// The image texture. /// The position of the image. public ImageLayer(string name, Texture2D texture, Vector2 position) : base(name) { Texture = texture; Position = position; } } }