fix: combat animation fix; add the death animation + delay;
This commit is contained in:
+12
-2
@@ -18,6 +18,9 @@ func _ready() -> void:
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _physics_process(delta: float) -> void:
|
||||
if SceneManager.player_hp <= 0:
|
||||
return
|
||||
|
||||
if not is_attacking:
|
||||
move_player()
|
||||
push_blocks()
|
||||
@@ -78,8 +81,8 @@ func _on_hit_box_area_2d_body_entered(body: Node2D) -> void:
|
||||
velocity += normalize_knockback * 500
|
||||
|
||||
func die():
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
SceneManager.player_hp = 3
|
||||
$AnimatedSprite2D.play("death")
|
||||
$DeathTimer.start()
|
||||
|
||||
func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
||||
var distance_to_enemy: Vector2 = body.global_position - global_position
|
||||
@@ -91,6 +94,8 @@ func _on_sword_area_2d_body_entered(body: Node2D) -> void:
|
||||
body.queue_free()
|
||||
|
||||
func attack():
|
||||
if not $Sword/SwordTimer.is_stopped():
|
||||
return
|
||||
var player_animation: String = $AnimatedSprite2D.animation
|
||||
if player_animation == "move_right":
|
||||
$AnimatedSprite2D.play("attack_right")
|
||||
@@ -125,3 +130,8 @@ func _on_sword_timer_timeout() -> void:
|
||||
$AnimatedSprite2D.play("move_up")
|
||||
if player_animation == "attack_down":
|
||||
$AnimatedSprite2D.play("move_down")
|
||||
|
||||
|
||||
func _on_death_timer_timeout() -> void:
|
||||
get_tree().call_deferred("reload_current_scene")
|
||||
SceneManager.player_hp = 3
|
||||
|
||||
Reference in New Issue
Block a user