All
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -15,5 +15,5 @@ func _ready() -> void:
|
||||
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
func _process(_delta: float) -> void:
|
||||
pass
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
extends Node
|
||||
class_name FacingDirectionComponent
|
||||
|
||||
@export var current_direction := Enums.Directions.DOWN
|
||||
|
||||
# Public Methods
|
||||
func GetCurrentDirection() -> Enums.Directions:
|
||||
return current_direction
|
||||
@@ -1 +0,0 @@
|
||||
uid://b0l02v61if6k8
|
||||
@@ -3,3 +3,14 @@ extends Node
|
||||
enum Directions {
|
||||
LEFT, RIGHT, UP, DOWN
|
||||
}
|
||||
|
||||
enum CheckLocations {
|
||||
SHOP_1, SHOP_2, SHOP_3
|
||||
}
|
||||
|
||||
enum Items {
|
||||
BRONZE_KEY, SILVER_KEY, GOLD_KEY,
|
||||
WOOD_SWORD, IRON_SWORD, ROYAL_SWORD,
|
||||
RED_POTION,
|
||||
GOLD_100, GOLD_200, GOLD_300, GOLD_400
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user