Is there a way that I can add shadow effect on text drawn in monogame? Because you cannot add shadow effect when creating a new spritefont file in Monogame Content Pipeline.

Thanks.

One way to do this, is to draw your text 2 times in a different color at specific offsets.

For example:

    public static void DrawText(SpriteBatch spritebatch, SpriteFont font, string text, Color backColor, Color frontColor, float scale, Vector2 position)
{
Vector2 origin = Vector2.Zero;

spriteBatch.DrawString(font, text, position + new Vector2(1 * scale, 1 * scale), backColor, 0, origin, scale, SpriteEffects.None, 1f);
spriteBatch.DrawString(font, text, position + new Vector2(-1 * scale, 1 * scale), backColor, 0, origin, scale, SpriteEffects.None, 1f);
//spriteBatch.DrawString(font, text, position + new Vector2(-1 * scale, -1 * scale), backColor, 0, origin, scale, SpriteEffects.None, 1f);
//spriteBatch.DrawString(font, text, position + new Vector2(1 * scale, -1 * scale), backColor, 0, origin, scale, SpriteEffects.None, 1f);

spriteBatch.DrawString(font, text, position, frontColor, 0, origin, scale, SpriteEffects.None, 0f);
}


Might be good enough for what you are trying to do.

• Thank you very much. What about creating a nice text outline? The two commented lines + the above are for it? – Edvin Jul 3 '15 at 16:46
• @Edvin Yes exactly, If you uncomment the two lines, it will produce an outline. – jgallant Jul 3 '15 at 16:47