I am looking for a way to run my animation a complete cycle when a button is pressed. The animation runs as long as the button is pressed but the animation takes a second to play so it becomes too short. I would like to have it played through once, even if the button only was pressed very fast.
It's a character's slash with the knife and it needs to be one complete cycle, I just don't get how to do this.
Anyone has an idea on how I could do this in a better way?
The specific code is now inside render():
if(Gdx.input.isKeyPressed(Input.Keys.SPACE)) {
if(direction == HEADING.NORTH) {
animation = knifeslashnorth;
} else if (direction == HEADING.WEST) {
animation = knifeslashwest;
} else if(direction == HEADING.EAST) {
animation = knifeslasheast;
} else if(direction == HEADING.SOUTH) {
animation = knifeslashsouth;
}
}