This commit is contained in:
2026-02-22 12:16:09 -06:00
parent 0ec11483f8
commit 63e2f75e7b
21 changed files with 657 additions and 282 deletions

View File

@@ -10,6 +10,26 @@ extends Node2D
@onready var shoes: AnimatedSprite2D = $Shoes
var all_parts: Array[AnimatedSprite2D]
var current_animation := "idle-down"
var is_flipped := false
# Public Methods
func UpdateSprite() -> void:
var current_state := state_machine.GetCurrentState()
var current_direction := direction_component.GetCurrentDirection()
var animation := _build_animation_name(current_state, current_direction)
var should_flip := _should_flip_horizontal()
if animation == current_animation and should_flip == is_flipped:
return
current_animation = animation
is_flipped = should_flip
for part in all_parts:
part.animation = animation
part.play()
part.flip_h = should_flip
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
@@ -17,12 +37,7 @@ func _ready() -> void:
base, hair, pants, hands, shoes
]
var animation := _build_animation_name(state_machine.GetCurrentState(), direction_component.GetCurrentDirection())
var should_flip := _should_flip_horizontal()
for part in all_parts:
part.animation = animation
part.play()
part.flip_h = should_flip
UpdateSprite()
func _build_animation_name(state: PlayerStateMachine.States, direction: Enums.Directions) -> String: