XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

SpriteFont transparency?

Last post 05-12-2008 3:08 AM by ernis. 3 replies.
  • 05-12-2008 2:34 AM

    SpriteFont transparency?

    Hi,

    sorry if this a dumb question, just starting out in XNA :)

    I'm trying to do 3D clock by using SpriteFont,but can't make drop shadow effect nicely.

    I have seen some examples in XNA 2.0 book which I didn't buy ( was for real beginers  ) and author
    did achieve this effect somehow buy using Alpha channel, but I don't remember how he did it.

    I think I'm missing something as in my case shadow is simply black..

    This is how I'm trying to draw shadow:

    1. // draw shadow by using alpha = 20 
    2.             for (int i = 0; i < 3; i++)
    3.             {
    4.                 pos.Y -= 1;
    5.                 pos.X -= 1;
    6.  
    7.                 spriteBatch.DrawString(myFont, sTime, pos, new Color(new Vector4(0, 0, 0, 20)), 0, Vector2.Zero, 1, SpriteEffects.None, 0);
    8.             }

    Code link http://pastebin.com/m7e71eba1



  • 05-12-2008 2:51 AM In reply to

    Re: SpriteFont transparency?

    When you call SpriteBatch begin you must specify a SpriteBlendMode to enable alpha blending. Your two choices are additive blending using SpriteBlendMode.Additive or alpha blending using SpriteBlendMode.Alpha.
  • 05-12-2008 2:53 AM In reply to

    Re: SpriteFont transparency?

    Also, when you use the Vector4 overload of Color's constructor, valid values are 0.0-1.0
    Regards,
    Louis Ingenthron
    Fortis Venaliter
    Lead Developer of FV Productions
  • 05-12-2008 3:08 AM In reply to

    Re: SpriteFont transparency?

    thanks guys for super quick replays! :)

    Problem was because values for Vector4 has to be between 0.0 - 1.0 as you've said.
Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG