diff --git a/behaviours/sprite_left_right.gd b/behaviours/sprite_left_right.gd new file mode 100644 index 0000000..d0fd4d1 --- /dev/null +++ b/behaviours/sprite_left_right.gd @@ -0,0 +1,13 @@ +extends Sprite2D +class_name SpriteLeftRight + + +@export var left_texture: Texture2D +@export var right_texture: Texture2D + + +func handle_move(movement: Vector2): + if movement.x > 0: + texture = right_texture + else: + texture = left_texture diff --git a/behaviours/sprite_left_right.tscn b/behaviours/sprite_left_right.tscn new file mode 100644 index 0000000..7064655 --- /dev/null +++ b/behaviours/sprite_left_right.tscn @@ -0,0 +1,6 @@ +[gd_scene load_steps=2 format=3 uid="uid://bxbjfev0lhwws"] + +[ext_resource type="Script" path="res://behaviours/sprite_left_right.gd" id="1_mt6ma"] + +[node name="SpriteLeftRight" type="Sprite2D"] +script = ExtResource("1_mt6ma")