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