School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!

Welcome to Dream.In.Code
Become an Expert!

Join 307,146 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 1,742 people online right now. Registration is fast and FREE... Join Now!




XNA Sprites

 

XNA Sprites

prabh

5 Oct, 2009 - 08:03 AM
Post #1

D.I.C Regular
Group Icon

Joined: 27 Dec, 2008
Posts: 292



Thanked: 8 times
Dream Kudos: 25
My Contributions
Hi


the first 2d tutorial on creators club made our first images for us

i'm having a problem
in that tute there was a cannon when you open it in photoshop it has a blue color, which becomes transparent at run time f the game we see only the cannon

i also tried to create one like that but that color does not becomes transparent



So,
my question is how do i create sprites like that

i googled but i didn't found any good results

Thanks



User is offlineProfile CardPM
+Quote Post


NeoTifa

RE: XNA Sprites

5 Oct, 2009 - 08:24 AM
Post #2

Yay caek! ZOMG!!!
Group Icon

Joined: 24 Sep, 2008
Posts: 6,533



Thanked: 83 times
Dream Kudos: 150
My Contributions
Maybe something to do with color filtering?
User is offlineProfile CardPM
+Quote Post

stayscrisp

RE: XNA Sprites

5 Oct, 2009 - 08:30 AM
Post #3

Mouth->Insert(Foot);
Group Icon

Joined: 14 Feb, 2008
Posts: 1,404



Thanked: 54 times
Dream Kudos: 300
My Contributions
I'm pretty sure XNA can load transparency with .png files or 24bit BMP files. Check out my tutorial for making them here.

But if you really want colour keying then use the content processor section in properties, you can set the colour key and colour key enabled properties from there.


User is offlineProfile CardPM
+Quote Post

prabh

RE: XNA Sprites

5 Oct, 2009 - 08:39 AM
Post #4

D.I.C Regular
Group Icon

Joined: 27 Dec, 2008
Posts: 292



Thanked: 8 times
Dream Kudos: 25
My Contributions
QUOTE(stayscrisp @ 5 Oct, 2009 - 08:30 AM) *

I'm pretty sure XNA can load transparency with .png files or 24bit BMP files. Check out my tutorial for making them here.

But if you really want colour keying then use the content processor section in properties, you can set the colour key and colour key enabled properties from there.

explain more clearly


and cannon image is tga file
User is offlineProfile CardPM
+Quote Post

stayscrisp

RE: XNA Sprites

5 Oct, 2009 - 10:35 AM
Post #5

Mouth->Insert(Foot);
Group Icon

Joined: 14 Feb, 2008
Posts: 1,404



Thanked: 54 times
Dream Kudos: 300
My Contributions
I am saying that you don't have to use colour keying, which is what you are talking about with the Cannon file. In fact I would recommend against it, use something such as a .png file which supports transparency without colour keying and looks a lot better.

Check out the tutorial link I gave you.


User is offlineProfile CardPM
+Quote Post

Ryxian

RE: XNA Sprites

5 Oct, 2009 - 11:15 AM
Post #6

New D.I.C Head
*

Joined: 13 Sep, 2009
Posts: 24



Thanked: 1 times
My Contributions
I think that the targa texture for the cannon in that tutorial has alpha channels. If you open the texture in Photoshop and go to the "channels" tab where the layers are, you'll see a layer called "Alpha". Click it and you'll see a black and white layer. The whiter, the more will be seen. Fully black, will be fully transparent, fully white will be fully shown, and so on. smile.gif

I think that stayscrisp is refering to alpha channels aswell, .png files support it too!
User is offlineProfile CardPM
+Quote Post

prabh

RE: XNA Sprites

6 Oct, 2009 - 10:31 AM
Post #7

D.I.C Regular
Group Icon

Joined: 27 Dec, 2008
Posts: 292



Thanked: 8 times
Dream Kudos: 25
My Contributions
QUOTE(Ryxian @ 5 Oct, 2009 - 11:15 AM) *

I think that the targa texture for the cannon in that tutorial has alpha channels. If you open the texture in Photoshop and go to the "channels" tab where the layers are, you'll see a layer called "Alpha". Click it and you'll see a black and white layer. The whiter, the more will be seen. Fully black, will be fully transparent, fully white will be fully shown, and so on. smile.gif

I think that stayscrisp is refering to alpha channels aswell, .png files support it too!

when you open cannon in GIMP it shows alpha channels like in photoshop(transparent areas are like checked flag)
User is offlineProfile CardPM
+Quote Post

SixOfEleven

RE: XNA Sprites

6 Oct, 2009 - 12:24 PM
Post #8

lives.ToCode();
Group Icon

Joined: 18 Oct, 2008
Posts: 3,066



Thanked: 171 times
Dream Kudos: 775
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
QUOTE(prabh @ 6 Oct, 2009 - 12:31 PM) *

when you open cannon in GIMP it shows alpha channels like in photoshop(transparent areas are like checked flag)


If you like GIMP you can use the transparency and save the files as 32-bit .png files. They work well for me.
User is offlineProfile CardPM
+Quote Post

Hellbroth

RE: XNA Sprites

8 Oct, 2009 - 09:44 AM
Post #9

D.I.C Head
**

Joined: 15 Aug, 2009
Posts: 53



Thanked: 1 times
My Contributions
QUOTE(SixOfEleven @ 6 Oct, 2009 - 12:24 PM) *

QUOTE(prabh @ 6 Oct, 2009 - 12:31 PM) *

when you open cannon in GIMP it shows alpha channels like in photoshop(transparent areas are like checked flag)


If you like GIMP you can use the transparency and save the files as 32-bit .png files. They work well for me.



I think the guy has a similar problem with me let me explain it more cause i did the same tutorial.

The cannon image has a blue color transparent Color.

but if you use some other sprite your transparent color will be shown.

For example i try to render a Akuma sprite which transparent color was pink but it was still shown when i run my project.

User is offlineProfile CardPM
+Quote Post

SixOfEleven

RE: XNA Sprites

8 Oct, 2009 - 01:31 PM
Post #10

lives.ToCode();
Group Icon

Joined: 18 Oct, 2008
Posts: 3,066



Thanked: 171 times
Dream Kudos: 775
Expert In: C, C#, XNA, Game Programming, Programming Concepts

My Contributions
GIMP, and I believe other image processing programs, have the ability to select by color. All you need to do is select the color and press delete to remove the color and make it transparent. Then just save as a 32-bit PNG file. That will solve the problem. If you are using Paint.NET there is the magic wand tool. Select that, set the thresh-hold to about 20% and then select the color and cut out the portion and save as a 32-bit PNG file. When making sprites with XNA I far prefer PNG to any other file format. Usually in XNA Magenta is usually considered transparent RGB #FF00FF. That might by why you have found the sprites with pink backgrounds. When you are calling Begin of the SpriteBatch object make sure to use SpriteBlendMode.AlphaBlend to enable transparency.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 11/21/09 03:50PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month