/// <summary> /// Construct UIImage /// </summary> /// <param name="sheet">Texture atlas</param> /// <param name="position">Start position</param> /// <param name="element">Atlas element</param> /// <param name="scaleX">Scale x</param> /// <param name="scaleY">Scale y</param> public UIImage(Texture2DSheet sheet, Vector2 position, int element = 0, int scaleX = 1, int scaleY = 1) : base(position, scaleX, scaleY) { texture = sheet; this.position = position; ScaleX = scaleX; ScaleY = scaleY; if (sheet != null) { SetElement(element); } childrens = new List <UIElement>(); }
/// <summary> /// Draw tilemap /// </summary> public override void Draw() { int min_x = CurrentX_chunk * (int)one_chunk_size.X; int min_y = CurrentY_chunk * (int)one_chunk_size.Y; int max_x = Math.Clamp(min_x + (int)one_chunk_size.X + smooth, 0, structure.GetUpperBound(0)); int max_y = Math.Clamp(min_y + (int)one_chunk_size.Y + smooth, 0, structure.GetUpperBound(0)); for (int x = Math.Clamp(min_x - smooth, 0, structure.GetUpperBound(0)); x < max_x; x++) { for (int y = Math.Clamp(min_y - smooth, 0, structure.GetUpperBound(1)); y < max_y; y++) { if (structure[x, y] != -1) { Texture2DSheet sheet = tiles[structure[x, y]].Sprite; Rectangle element = tiles[structure[x, y]].CurrentElement; Core.spriteBatch.Draw(sheet.texture, new Vector2(x * TileX, y * TileY), element, Color.White, 0, Vector2.Zero, 1, SpriteEffects.None, 0); } } } }
/// <summary> /// Construct UIButton /// </summary> /// <param name="sheet">Texture atlas</param> /// <param name="position">Start position</param> /// <param name="element">Atlas element</param> /// <param name="scaleX">Scale x</param> /// <param name="scaleY">Scale y</param> public UIButton(Texture2DSheet sheet, Vector2 position, int element = 0, int scaleX = 1, int scaleY = 1) : base(sheet, position, element, scaleX, scaleY) { }