Slick Transparent Color

Hey, everybody!

I’m having a slight problem using Slick and getting transparent colors working with SpriteSheets and Animations. Here’s the code I have to load a SpriteSheet and create two Animations from it in my game engine:


/*
     * Loads sprites for all creature-based entities, including the player, and compiles their animations.
     */
    public void loadCreatureSprites() 
    {
        // spritesheet to hold all of the player's frames
        SpriteSheet sheet = null;
        
        try
        {
            sheet = new SpriteSheet("resources/images/playersheet.png", 60, 72, new Color(Vast.COLOR_KEY));
        }
        catch (SlickException ex)
        {
            ex.printStackTrace();
        }
        
        Animation playerAnim1 = new Animation(sheet, 80);
        Animation playerAnim2 = new Animation();
        
        for (int i = 0; i < playerAnim1.getFrameCount(); i++)
        {
            playerAnim2.addFrame(playerAnim1.getImage(i).getFlippedCopy(true, false), 80);
        }

        // create creature sprites
        playerSprite = new Player(playerAnim2, playerAnim1, playerAnim1, playerAnim1);
    }

The Animations load and play when I move about, but the color around the images that I’ve designated as a key still shows up (it’s a bright pink color, whose hex value is defined in a separate class called Vast, hence Vast.COLOR_KEY). I’m not sure if there’s something I’m missing here, but I would really like to use Slick’s Animations and SpriteSheets rather than having to roll my own because of this color key issue, and if I try and give my .png images their own alpha channels to circumvent the issue, the alpha just loads as black in the game.

Thanks a lot for your help! :]

Colton

Slick’s “transparent color” parameter is bugged in the latest code.

If you have photoshop, GIMP or Paint.NET you should be able to pretty easily remove the color and save it as a transparent PNG.

davedes,

I understand. However, I tried implementing an alpha channel in an image I exported, but loading the SpriteSheet with Slick results in the image filling in all of the “transparent” color with black. Is there a fix that you know of for this? Thank you for your time!

Colton