summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Components/Movement.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-05-03 09:32:22 +0200
committerDaniel Weipert <git@mail.dweipert.de>2024-05-03 09:32:22 +0200
commit516d22c1737a9c94026b5ff0c9856bc5549aa416 (patch)
treecd9ef3089d1c8bdfc440b5673f7ad0d0dce787a9 /Scenes/Entities/Enemies/Components/Movement.gd
parentd192b1546ab39180cdc28d2621c117539e3d26d6 (diff)
update
Diffstat (limited to 'Scenes/Entities/Enemies/Components/Movement.gd')
-rw-r--r--Scenes/Entities/Enemies/Components/Movement.gd16
1 files changed, 15 insertions, 1 deletions
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()