From 516d22c1737a9c94026b5ff0c9856bc5549aa416 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Fri, 3 May 2024 09:32:22 +0200 Subject: update --- Scenes/Entities/Enemies/Components/Movement.gd | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Scenes/Entities/Enemies/Components/Movement.gd') diff --git a/Scenes/Entities/Enemies/Components/Movement.gd b/Scenes/Entities/Enemies/Components/Movement.gd index 28b374d..5470a7d 100644 --- a/Scenes/Entities/Enemies/Components/Movement.gd +++ b/Scenes/Entities/Enemies/Components/Movement.gd @@ -1,3 +1,4 @@ +class_name ComponentMovement extends Node @@ -41,7 +42,7 @@ func physics_process(delta): sprite.play("down") elif CURRENT_DIRECTION == Vector2.LEFT: entity.velocity.x -= SPEED - if sprite.sprite_frames.has_animation("leftup"): + if sprite.sprite_frames.has_animation("left"): sprite.play("left") elif CURRENT_DIRECTION == Vector2.RIGHT: entity.velocity.x += SPEED @@ -96,4 +97,17 @@ func _on_movement_timer_timeout(): emit_signal("direction_changed", CURRENT_DIRECTION) LAST_DIRECTION = CURRENT_DIRECTION + if not sprite.sprite_frames.has_animation("default"): + var frame = sprite.frame + var progress = sprite.frame_progress + if CURRENT_DIRECTION == Vector2.UP and sprite.sprite_frames.has_animation("up"): + sprite.play("up") + elif CURRENT_DIRECTION == Vector2.DOWN and sprite.sprite_frames.has_animation("down"): + sprite.play("down") + elif CURRENT_DIRECTION == Vector2.LEFT and sprite.sprite_frames.has_animation("left"): + sprite.play("left") + elif CURRENT_DIRECTION == Vector2.RIGHT and sprite.sprite_frames.has_animation("right"): + sprite.play("right") + sprite.set_frame_and_progress(frame, progress) + MovementTimer.start() -- cgit v1.2.3