# Transparency working for tiles but not for srpite [SDL]

## Recommended Posts

JDUK    100
I have the simple begginings of an isometric tile engine into which i have loaded a small tiled area with 0,0xFF, 0xFF transparency that works fine. I have just chucked a sprite on screen with exactly the same transparence... i've even set the colorkey off of the sprite to make sure... but the sprite is still showing its background like so: These are the exact images being used This is the Code in main() that loads up the images and sets transparency:
screen = SDL_SetVideoMode( SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, SDL_SWSURFACE );
Uint32 colorkey = SDL_MapRGB( Sprite->format, 0, 0xFF, 0xFF );
SDL_SetColorKey( Tiles, SDL_RLEACCEL | SDL_SRCCOLORKEY, colorkey );


And this is my load_image function:
SDL_Surface *load_image (std::string filename)
{
SDL_Surface *Image = NULL;
//Create a loader for the image
{
//Transform the image to match the Display Format.
}
return Image;
SDL_FreeSurface(Image);
}



##### Share on other sites
TFS_Waldo    146
You have to call "SDL_MapRGB" for "Tiles" and "Sprite", then make a call to "SDL_SetColorKey" for "Tiles" and "Sprite". In the code provided, you set the color key for "Sprite", and used the color key for transparency ("SDL_SetColorKey") on "Tiles". =) =P

##### Share on other sites
JDUK    100
Doh!
Cheers

Im a total muppet.

##### Share on other sites
TFS_Waldo    146
Hey, it wasn't a problem. I don't know about everyone else, but I make simple mistakes like that all the time. I want to slap myself everytime I do something like that. But I've learned to double-check EVERYTHING that is part of, or might be part of, and error I receive. Before I post on the forums. (*whisper*) So no one else can see my stupidity. LoL =P