Jump to content
  • Advertisement
Sign in to follow this  
BlackDragon

[.net] XNA sprite question

This topic is 3991 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello, I'm am trying to create a sprite that has transparent parts. I cant seem to figure out how to do it using XNA. I have tries using the code below but it doesnt seem to do anything. TextureCreationParameters tcp = Texture2D.GetCreationParameters(graphics.GraphicsDevice, @"C:\XNA\Sprites\Sprites\Content\Up-Left02.bmp"); tcp.ColorKey = Color.Black; Sprite = Texture2D.FromFile(graphics.GraphicsDevice, @"C:\XNA\Sprites\Sprites\Content\Up-Left02.bmp",tcp); Where are some good spots to learn XNA programming? Thanks

Share this post


Link to post
Share on other sites
Advertisement
This should help you with that.

http://msdn2.microsoft.com/en-us/library/bb203867.aspx

Also you should read up on the XNA content pipeline. It makes loading files, textures and shaders much nice and cleaner.

To get started, go to XNA in your Start menu and go to the XNA Documentation, then select "Getting Started with XNA Game Studio Express", then select "Going Beyond: XNA Game Studio Express in 3D", do the three tutorials in there. That will give you a good basic start to XNA.

theTroll

Share this post


Link to post
Share on other sites
The easiest way to do it is to export your sprite (sheet) as a PNG file and use the content manager to load it. The content manager does exactly what you think it would do: your Texture2D has an alpha channel and the SpriteBatch instance takes this into account even if you don't tell him to do so.

HTH,

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!