I am new to Godot and recently watched a few tutorial on character animations through YT
I have code a character with basic movements (ie. walking, head butt and jump).
However, I am not sure how to code the air spinning animations.
Here is what I am looking for

I have the animation in 4 frames:

The first 2 frames are use when press the button 1 time, the last 2 frames are used when press the button again, and then repeat when he button is press again N times.
Here is the code I have for my code so far:
match player_state:
Animation_States.AIR:
if is_on_floor():
player_state = Animation_States.FLOOR
continue
$AnimatedSprite.play("Jump")
if Input.is_action_pressed("Left") && isAttacking == false:
# Change animation when falling
if velocity.y > 0:
$AnimatedSprite.play("Falling")
velocity.x = -DEFAULT_WALK_SPEED
$AnimatedSprite.flip_h = true
elif Input.is_action_pressed("Right") && isAttacking == false:
# Change animation when falling
if velocity.y > 0:
$AnimatedSprite.play("Falling")
velocity.x = DEFAULT_WALK_SPEED
$AnimatedSprite.flip_h = false
else:
if velocity.y > 0:
$AnimatedSprite.play("Falling")
velocity.x = lerp(velocity.x, 0, 0.18)
move_and_fall()
Animation_States.FLOOR:
if not is_on_floor():
player_state = Animation_States.AIR
continue
if Input.is_action_pressed("Left") && isAttacking == false:
velocity.x = -DEFAULT_WALK_SPEED
$AnimatedSprite.flip_h = true
$AnimatedSprite.play("Walk")
if velocity.x != 0 and is_on_floor():
if !$Walk.playing:
$Walk.play()
elif $Walk.playing:
$Walk.stop()
elif Input.is_action_pressed("Right") && isAttacking == false:
velocity.x = DEFAULT_WALK_SPEED
$AnimatedSprite.flip_h = false
$AnimatedSprite.play("Walk")
if velocity.x != 0 and is_on_floor():
if !$Walk.playing:
$Walk.play()
elif $Walk.playing:
$Walk.stop()
else:
if isAttacking == false:
$AnimatedSprite.play("Idle")
velocity.x = lerp(velocity.x, 0, 0.13)
if Input.is_action_just_pressed("Jump"):
velocity.y = JUMPFORCE
$Jump.play()
player_state = Animation_States.AIR
if Input.is_action_just_pressed("Headbutt"):
velocity.x = 0
$AnimatedSprite.play("Headbutt")
$Headbutt.play()
isAttacking = true
move_and_fall()
func move_and_fall():
velocity.y += GRAVITY
velocity = move_and_slide(velocity, Vector2.UP)
func _on_AnimatedSprite_animation_finished():
if $AnimatedSprite.animation == "Headbutt":
isAttacking = false
The Falling animation is a different animation...