How can I make the background of my sprite always draw transparent?
Printable View
How can I make the background of my sprite always draw transparent?
Use the alpha channel for your images. An alpha of 1 means it's fully opaque, an alpha of 0 means it's fully transparent, and you can also use any alpha value in-between 0 and 1 (note: depending on the format this might be a byte 0-255 rather than a float 0-1).
This means you'll have to choose a format that supports alpha channels (png, tif, etc.), or you can create masks for your images (much more difficult, as well as performing worse than using an image with alpha).
I'm still a little confused. How would I do it if I want the color pink to appear clear.
Provide adequate context. As it stands, your question could have a gadzillion answers, some of which would involve scissors or acid.
How To Ask Questions The Smart Way
SSCCE : Java Glossary
db
I painted the background of my sprite pink. I want to convert the pink to transparent so it looks like my sprite is walking on the background.
load your image in an application that can edit alpha values (photoshop, gimp, there are some other ones, but MS paint does not support this). Then, everywhere there is a pink pixel you don't want to be visible, use the tool provided by your specific application to change the alpha channel to 0. If you're unsure how to do this, a quick google search should provide this information.
Once you've removed the alpha channel, you need to load the image acknowledging that there are 4 channels (RGBA). TYPE_4BYTE_ABGR will work for this, as will TYPE_INT_ARGB. You should be able to paint the image as normal and the channels marked as having 0 alpha will be completely transparent (or invisible).
Thank you!