Transparency working for tiles but not for srpite [SDL]

Started by
2 comments, last by TFS_Waldo 18 years, 5 months ago
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: Image These are the exact images being used Image Image 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 );
Tiles = load_image("Tiles.bmp");
Sprite = load_image("Sprite.bmp");
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_Loader = NULL;
  SDL_Surface *Image = NULL;
  //Create a loader for the image
  Image_Loader = SDL_LoadBMP(filename.c_str());
  if(Image_Loader != NULL)
  {
    //Transform the image to match the Display Format.
    Image = SDL_DisplayFormat(Image_Loader);  
    //Free up the loader again.
    SDL_FreeSurface(Image_Loader);  
  }
  return Image;
  SDL_FreeSurface(Image); 
}



Advertisement
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
:==-_ Why don't the voices just leave me alone?! _-==:
Doh!
Cheers

Im a total muppet.
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
:==-_ Why don't the voices just leave me alone?! _-==:

This topic is closed to new replies.

Advertisement