I've been working with Slick2d for a few weeks now and I really enjoy it (since I'm a native Java developer). I began development of a small game, but my animation rendering isn't working the way it's suppose to. The following is my code for the class where I'm having trouble:
public class Player extends Entity{
private int duration = 600;
Animation tmp = new Animation();
public Player(int x, int y, int w, int h) {
super(x, y, w, h);
}
@Override
public void render(GameContainer gc, Graphics g) {
setAnimations();
g.drawAnimation(tmp, 100,100);
}
@Override
public void update(GameContainer gc) {
if(tmp.isStopped()){
tmp.start();
}
else
tmp.stop();
}
@Override
public void setAnimations() {
Image[] tempImage = new Image[3];
for(int i = 6, j = 0; i < 9; i++){
tempImage[j] = prototypeCo2Graphics.spriteSheet[0];
j++;
}
//tmp.addFrame(prototypeCo2Graphics.spriteSheet[5][0],duration);
for(Image i : tempImage)
tmp.addFrame(i, duration);
animations.add(tmp);
}
}
What happnes is that the image renders unto screen, but the animation is way too fast. (Frame 1 display longer, and Frame 2 and 3 simply just flash). Any Help would be greatly appreciated, thank you.