gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Graphics > Question about sprites

#56282 - sparda - Fri Oct 07, 2005 5:10 pm

Ok i have a problem and a question, i will give an example to explain.

When i draw a sprite to the screen, it could be any shape( 8x8, 16x16, ect.)
I see the sprite, but i also see a white box! ??

for example, if the sprite shape is 16x16, The sprite would be inside the 16x16 White box, I know that (0) represents Transparent, but i dont know how to make the white area around my sprite be transparent. I want the sprite and only the sprite to show on-screen.

So my question is, How can i make the surrounding area around a Sprite transparent instead of white?

Im using Adobe Photoshop CS to create my sprites, and Dovoto's PCX2Sprite utility to convert the sprites into source files.

any help would be appreciated, thanks.
_________________
genius is 1% inspiration, 99% perspiration .

#56295 - DiscoStew - Fri Oct 07, 2005 6:59 pm

It would appear that the white box surrounding your sprite is not the index color 0, which is the index that any transparency takes place. Go to the Tools section of GBADev.org, and find PaletteTool. With that, you load up your image, then examine your palette (you can also display your image at the same time), and then take 2 colors (index 0, and whatever index this white color is), and swap them and save settings. With that, it should then make the white area reference itself to index 0, and be cut away.

However, make sure this specific index isn't being used by your image anywhere else other than the places where you don't want it to show up. With programs like Photoshop, it is possible that the white color meant for transparency might also be used somewhere else on your sprite, but is meant to be shown.
_________________
DS - It's all about DiscoStew

#56780 - thegamefreak0134 - Tue Oct 11, 2005 1:53 pm

Ahh. adobe photoshop. I see your problem.

If my memory serves me right, Adobe completely reverses your pallete when you save PCX images. Therefore, the LAST color in the pallete ends up being the transparent one. This should solve your problem.

What works for me is to open the PCX image, edit the color table (Image >> mode >> color table), change the last color to transparent (pick something like hot pink thats not in your picture),save it as a file, and then load the table into the color swatch pane. That way, the transparent color is right there and there is no forgetting or anything. After that, paint all of the transparent parts of the picture making sure to use that color you just put there. This should work.

Also, remember when you go down the line that all of your sprites use the same palette. Pick one transparent color and stick with it, or you will have serious issues later.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]

#58560 - thegamefreak0134 - Mon Oct 24, 2005 4:47 pm

I'm correcting myself. If you're using 256 color sprites, they all have to have the same colors and transparent of course. However, in 16 color mode each different palette can have a different transparent color. My bad.
_________________
What if the hokey-pokey really is what it's all about?

[url=http:/www.darknovagames.com/index.php?action=recruit&clanid=1]Support Zeta on DarkNova![/url]