public void animation()
{
animationStand.start(); //keep looping
if(isHit) //if player get hit
animationPlaneHit.start(); //loop though onces but doesnt work
animationStand.update();
animationPlaneHit.update();
}
........
public void paint(...)
{
//make player standing a animation between two images.
//if player get hit set flag to true. isHit is only true when player get hit. soon as he is not hit it
//turn to false. so if flag is true make animation.
g.drawImage(animationStand.getSprite(), (int)x,(int)y, width, height, null);
if(isHit)
flag = true;
if(flag)
g.drawImage(animationPlaneHit.getSprite(), (int)x,(int)y, width, height, null);
}

I only just realized your post is Java, and my recommendation is C++. However, the basic logic is still of use to you. I dunno if there are enums in Java, but you could just easily use integer values or, a bool.

]**

In your SpriteAnimation class add this:

enum PlayBackMode{Loop, PlayOnce};
PlayBackMode playMode;

Then you'll have to set the PlaneHit animation's playMode = PlayOnce. And the update function should be:

You need to tell the code that the animation stops when it reaches the max amount of frames. You don't do that in your original code, as far as I know. I'm also confused by currentFrame += animationDirection and the else if that checks if currentFrame is less than 0. When would that ever happen?

Liuqahs suggested an enum, which is generally a good idea, but if you haven't learned those yet you could use a simple boolean, egboolean playOnce = (true or false depending on the type of Sprite)
then if it's true you stop the animation after the last frame, but if its false you go back to the first frame

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...