Home > Software design >  How do I slow down an a sprite animation with processing java
How do I slow down an a sprite animation with processing java

Time:06-10

I'm attempting to slow down a sprite animation that I found from this website here: enter image description here

And here's what I want it to look like:

enter image description here

Thanks for any help.

CodePudding user response:

You're sooo close ! :)

You've got the solution pretty much using frameCount, just need to separate the frame update from the drawing. You want to update based on the frameCount (every once in a while), but display continuously:

void display(float xpos, float ypos) {
    if(frameCount % 12 == 0){
      frame = (frame 1) % imageCount;
    }
    image(images[frame], xpos, ypos);
}

(feel to ajust 12 (60/5) to what suits your project best)

Shameless plug, you can also use the image-sequence-player library I wrote which allows you to call setDelay(1000/5) to have the image sequence play at 5fps.

  • Related