Sign in to follow this  
JDUK

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: 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); 
}



Share this post


Link to post
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 this post


Link to post
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this