Beispiel #1
0
 public override void Draw(SpriteBatch spriteBatch)
 {
     if (!IsShow)
     {
         return;
     }
     if (BaseTexture != null)
     {
         BaseTexture.Draw(spriteBatch, ScreenPosition, Width, Height);
     }
 }
Beispiel #2
0
        public override void Draw(SpriteBatch spriteBatch)
        {
            if (!IsShow)
            {
                return;
            }

            if (BaseTexture != null && Width > 0 && Height > 0)
            {
                var position = ScreenPosition - new Vector2(Anchor.X * Width, Anchor.Y * Height);
                BaseTexture.Draw(spriteBatch, position, Width, Height);
            }
        }
Beispiel #3
0
        public virtual void Draw(SpriteBatch spriteBatch)
        {
            if (!IsShow)
            {
                return;
            }

            if (IsClicked && ClickedTexture != null)
            {
                ClickedTexture.Draw(spriteBatch, ScreenPosition);
            }
            else if (IsMouveOver && MouseOverTexture != null)
            {
                MouseOverTexture.Draw(spriteBatch, ScreenPosition);
            }
            else if (BaseTexture != null)
            {
                BaseTexture.Draw(spriteBatch, ScreenPosition);
            }
        }
Beispiel #4
0
        /// <summary>
        /// Draws the sub sprite with the given index from the atlas
        /// </summary>
        /// <param name="sb"></param>
        /// <param name="index"></param>
        /// <param name="dest"></param>
        /// <param name="source"></param>
        /// <param name="color"></param>
        public void Draw(SpriteBatch sb, string spriteDef, Rectangle dest, Rectangle?source = null, Color?color = null, Vector2?scale = null, Vector2?origin = null, float rotation = 0)
        {
            Rectangle def;
            bool      res = SpriteDefinitions.TryGetValue(spriteDef, out def);

            if (!res)
            {
                ConsoleManager.Instance.WriteLine($"Could not find sprite '{spriteDef}' in '{BaseTexture.Path}'");
                return;
            }

            if (source == null)
            {
                source = new Rectangle(0, 0, def.Width, def.Height);
            }
            if (color == null)
            {
                color = Color.White;
            }

            Rectangle finalSource = new Rectangle(def.X + source.Value.X, def.Y + source.Value.Y, source.Value.Width, source.Value.Height);

            BaseTexture.Draw(sb, dest, finalSource, color, scale, origin, rotation);
        }