Jump to content

  • Log In with Google      Sign In   
  • Create Account

Slick 2D Rendering Animation Trouble


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 ghigared   Members   -  Reputation: 133

Like
0Likes
Like

Posted 09 January 2013 - 11:16 AM

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[i][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.



Sponsor:

#2 KnolanCross   Members   -  Reputation: 1294

Like
0Likes
Like

Posted 09 January 2013 - 04:04 PM

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.


Edited by KnolanCross, 09 January 2013 - 04:04 PM.

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





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS