I found this tutorial on sprite sheets that works great. How can I make a sprite-sheet-based animation system?
I am not sure how I could modify it, so that it loops through just once. My thought was to add an if statement in the update method. This way I could stop the animation, but I am unable to figure out what to put in the if statement.
public void update() { if (!stopped) { frameCount++; if (frameCount > frameDelay) { frameCount = 0; currentFrame += animationDirection; if (currentFrame > totalFrames - 1) { currentFrame = 0; if(){ stopped = true; } } else if (currentFrame < 0) { currentFrame = totalFrames - 1; } } } }