Sign in to follow this  
TickledPink

XNA Sprites question

Recommended Posts

Just a quick question on sprites in XNA. How do I create a sprite where a particular colour is transparent? In other libraries in the past it used to be a pinky colour (IIRC Allegro was one that used that colour). Anyway, I've created some simple Isometric blocks in Photoshop with a transparent background but when saved in BMP format they're saved with a white background. At the moment the sprites are being displayed in my program with that white background.

Share this post


Link to post
Share on other sites
I don't know about how XNA works etc, but ,regarding the image files, .bmp files don't hold transparency information. So you could save them as .png maybe and keep the transparent background.

Share this post


Link to post
Share on other sites
Alternative method is to save them with a black background and to use additive blending when you render the sprites (spriteBatch.Begin(SpriteBlendMode.AdditiveBlend)) - black areas will then be completely transparent. But the preferred way is to use a PNG file anyway (because you have a finner control over which area should be transparent in your sprite).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this