Display sprites with transparent background

Advanced game related topics
yabune
User
User
Posts: 65
Joined: Mon Aug 22, 2005 2:31 pm

Display sprites with transparent background

Post by yabune »

Is it possible to display a png file with a transparent background?

I tried the DisplayTransparentSprite but it doesn't work with a 'transparent color'.

Do I have to paint the background of the png with a solid color?

thanks!
mskuma
Enthusiast
Enthusiast
Posts: 573
Joined: Sat Dec 03, 2005 1:31 am
Location: Australia

Re: Display sprites with transparent background

Post by mskuma »

yabune wrote:Do I have to paint the background of the png with a solid color
Yes, or you can do it using 3d sprites using a 32-bit PNG (with alpha) using something like:

Code: Select all

spriteNumber = LoadSprite(#PB_Any, PNGFilename, #PB_Sprite_Texture | #PB_Sprite_AlphaBlending)
sprite3DNumber = CreateSprite3D(#PB_Any, spriteNumber)
which maps the PNG as a texture to a 3D sprite, which I think is always facing the user, so in this way it will appear as a regular 2D image.
dracflamloc
Addict
Addict
Posts: 1648
Joined: Mon Sep 20, 2004 3:52 pm
Contact:

Post by dracflamloc »

Or you can set the transparent color of that sprite to RGB(0,0,0) which is what PB translates the transparent color in png to.
Post Reply