Can someone send my a simple code that's like this but will the object will go back to the stand image when ever key is let go.
public void moveRight() { setLocation(getX()+speed, getY()); if(animationCounter % 1 == 0) animateRight(); } public void moveLeft() { setLocation(getX()-speed, getY()); if(animationCounter % 1 == 0) animateLeft(); } public void checkKeyPress() { if(Greenfoot.isKeyDown("left")) { moveLeft(); } else if(Greenfoot.isKeyDown("right")) { moveRight(); } else if(Greenfoot.isKeyDown("up") && jumping == false) { jump(); } else { fall(); jumping = false; } } private void animateRight() { if(frame == 1) { setImage(runLeft1); if(animationCounter % 4 == 0) frame = 2; } else if(frame == 2) { setImage(runLeft2); if(animationCounter % 4 == 0) frame = 3; } else if(frame == 3) { setImage(runLeft3); if(animationCounter % 4 == 0) frame = 4; } else if(frame == 4) { setImage(runLeft4); if(animationCounter % 4 == 0) frame = 5; } else if(frame == 5) { setImage(runLeft5); if(animationCounter % 4 == 0) frame = 6; } else if(frame == 6) { setImage(runLeft6); if(animationCounter % 4 == 0) frame = 7; } else if(frame == 7) { setImage(runLeft7); if(animationCounter % 4 == 0) frame = 8; } else if(frame == 8) { setImage(runLeft8); if(animationCounter % 4 == 0) frame = 9; } else if(frame == 9) { setImage(runLeft9); if(animationCounter % 4 == 0) frame = 1; } } private void animateLeft() { if(frame == 1) { setImage("Run5.png"); if(animationCounter % 4 == 0) frame = 2; } else if(frame == 2) { setImage("Run6.png"); if(animationCounter % 4 == 0) frame = 3; } else if(frame == 3) { setImage("Run7.png"); if(animationCounter % 4 == 0) frame = 4; } else if(frame == 4) { setImage("Run8.png"); if(animationCounter % 4 == 0) frame = 5; } else if(frame == 5) { setImage("Run9.png"); if(animationCounter % 4 == 0) frame = 6; } else if(frame == 6) { setImage("Run11.png"); if(animationCounter % 4 == 0) frame = 7; } else if(frame == 7) { setImage("Run12.png"); if(animationCounter % 4 == 0) frame = 8; } else if(frame == 8) { setImage("Run13.png"); if(animationCounter % 4 == 0) frame = 9; } else if(frame == 9) { setImage("Run14.png"); if(animationCounter % 4 == 0) frame = 1; } }