Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Sprite transparency

Author
Message
hero_bash
16
Years of Service
User Offline
Joined: 3rd May 2008
Location:
Posted: 4th May 2008 03:20
I'm using png for a sprite.. How do you choose the transparent color for displaying the sprite?

Stand tall and shake the heavens
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th May 2008 08:13 Edited at: 4th May 2008 08:24
if the png file has alpha channel transparency, just load the file with the transparency flag. (whether it uses alpha trans or not, still load the image this way) ie,

load image "myFile.png",ImageNumber, 1

if it doesn't have alpha channel transparency, you'll need to use:

set image colorkey R,G,B

...before you load the image. ie, if the image uses pure Black (rgb 0,0,0) as the transparent color, then

set image colorkey 0,0,0

some use Magenta for the transparent color, so:

set image colorkey 255,0,255

...etc. (a specific rgb value for transparency is set upon file creation so you'll have to know the RGB value specific for that particular file. black and magenta are probably the most common colors used for transparency).

then, when you go to use the image as a sprite, use the set sprite command with the transparency flag set to 1. ie,

set sprite MySprite, 0, 1

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th May 2008 14:40
no offense taken, WindowsKiller. i'm far from a pro (i'll be the first to admit i don't know much!)

so, what do you do when the png doesn't have built-in transparency? i just tested one without transparency and set image colorkey had no effect on it. i assumed it would use the colorkey value <shugs>. also, in the past when i didn't use the texture flag on load image, the sprites/textures look "less than perfect" (at best) so i always use the ,1 flag (and, i expected everyone else did the same). <another shrug>

sorry for the confusion, hero-bash.

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP
pcRaider
17
Years of Service
User Offline
Joined: 30th May 2007
Location:
Posted: 4th May 2008 14:59
color key.
alpha channel.
Transparency of Sprite has two kinds of methods.
In addition, and we are complexed because DBP chooses it automatically.
Besides, many options.
Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 4th May 2008 23:59
thanks i know png's can be built without alpha or transparency ("back in the day" some people used them as an alternative to .gif's for internet purposes) so i figured that practice might still be in use. apparently not so here since colorkey doesn't work on them. again, thanks for the lesson.

Virtual Nomad
AMD XP 1800+ (~1.6 Ghz) / 1.5 GB RAM
ATI Radeon 8700LE 128 MB / Windows XP

Login to post a reply

Server time is: 2024-11-26 00:48:51
Your offset time is: 2024-11-26 00:48:51