summaryrefslogtreecommitdiff
path: root/Scenes/Entities/Enemies/Components/Movement.gd
diff options
context:
space:
mode:
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()