That's because in your keyReleased() method, you call stand(), which I gather sets the animation to the standing animation (or the standing sprite, whatever). You probably want to check which key was...
Type: Posts; User: KevinWorkman
That's because in your keyReleased() method, you call stand(), which I gather sets the animation to the standing animation (or the standing sprite, whatever). You probably want to check which key was...
Well, you set punching and kicking to false when the button is released, so that's going to cause the animation to stop.
I think what you want to do is force that animation to play the whole way...
The problem is, you don't need a for loop at all. The only time you want to increment the sprite being displayed is in the Timer's ActionListener.
I'm not sure when you're calling that walk() function, but I'm going to assume you're calling it from a KeyListener. Instead of doing that, you want to simply set a boolean from the KeyListener-...
If I were you, I would put the Timer in your top-level game class. I would give it control over everything in the game- each frame, it calls a method of each game object, updating it, doing collision...
The for loop you're using is going to be over and done in a matter of milliseconds (if not faster), so you aren't going to see any of the images, just the last one. You want to introduce a pause in...
I think the gist of what you want to do is have a game loop (probably using a Swing Timer) that constantly updates the game state. Then you could have a KeyListener that determines which animation...