Пример #1
0
        public static void DrawSpriteFrame(this SpriteBatch spriteBatch, Texture2D texture, Rectangle bounds, Align align, Color color, float rotation, float scale, Vector2 origin, int frameCount, int frameIndex, Vector2 shadowOffset, Color shadowColor)
        {
            var size = new Vector2(texture.Width / frameCount, texture.Height) * scale;

            if (shadowOffset != Vector2.Zero)
            {
                spriteBatch.Draw(texture, align.Offset(size, bounds, origin, scale) + shadowOffset, new Rectangle(new Vector2(texture.Width / frameCount * frameIndex, 0).ToPoint(), new Vector2(texture.Width / frameCount, texture.Height).ToPoint()), shadowColor, rotation, origin, scale, SpriteEffects.None, 0f);
            }
            spriteBatch.Draw(texture, align.Offset(size, bounds, origin, scale), new Rectangle(new Vector2(texture.Width / frameCount * frameIndex, 0).ToPoint(), new Vector2(texture.Width / frameCount, texture.Height).ToPoint()), color, rotation, origin, scale, SpriteEffects.None, 0f);
        }
Пример #2
0
        public static void DrawSprite(this SpriteBatch spriteBatch, Texture2D texture, Rectangle rect, Rectangle bounds, Align align, Color color, float rotation, Vector2 scale, Vector2 origin, Vector2 shadowOffset, Color shadowColor)
        {
            var size = new Vector2(texture.Width, texture.Height) * scale;

            if (shadowOffset != Vector2.Zero)
            {
                spriteBatch.Draw(texture, align.Offset(size, bounds, origin, scale) + shadowOffset, rect, shadowColor, rotation, origin, scale, SpriteEffects.None, 0f);
            }
            spriteBatch.Draw(texture, align.Offset(size, bounds, origin, scale), rect, color, rotation, origin, scale, SpriteEffects.None, 0f);
        }
Пример #3
0
        public static void DrawString(this SpriteBatch spriteBatch, SpriteFont font, string text, Rectangle bounds, Align align, Color color, Vector2 shadowOffset, Color shadowColor)
        {
            var size = font.MeasureString(text);

            if (shadowOffset != Vector2.Zero)
            {
                spriteBatch.DrawString(font, text, align.Offset(size, bounds) + shadowOffset, shadowColor, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);
            }
            spriteBatch.DrawString(font, text, align.Offset(size, bounds), color, 0, Vector2.Zero, 1f, SpriteEffects.None, 0f);
        }
Пример #4
0
 public static Vector2 Offset(this Align align, Vector2 size, Rectangle bounds, Vector2 origin, float scale) => align.Offset(size, bounds, origin, new Vector2(scale, scale));
Пример #5
0
 public static Vector2 Offset(this Align align, Vector2 size, Rectangle bounds) => align.Offset(size, bounds, Vector2.Zero, Vector2.One);