Slick 2D Rendering Animation Trouble

Started by
0 comments, last by KnolanCross 11 years, 3 months ago

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.

Advertisement

Not knowing this lib the only thing that comes to my mind is that duration is the time to switch the frame, not the time the frame should last. If that would be the case it would run the first from 0 to 600 (probably ms), and the other two from 600 to 600 (in this case, would just flash).

Have you tried seting the duration to 600, 1200, 1800? Also, have you check if the values are really correct? Maybe something is changing it.

Currently working on a scene editor for ORX (http://orx-project.org), using kivy (http://kivy.org).

This topic is closed to new replies.

Advertisement