mirror of
https://github.com/Steffo99/hella-farm.git
synced 2024-11-21 23:54:23 +00:00
Create SpriteLeftRight
behaviour
This commit is contained in:
parent
0a1f302c77
commit
2b513b8bb2
2 changed files with 19 additions and 0 deletions
13
behaviours/sprite_left_right.gd
Normal file
13
behaviours/sprite_left_right.gd
Normal file
|
@ -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
|
6
behaviours/sprite_left_right.tscn
Normal file
6
behaviours/sprite_left_right.tscn
Normal file
|
@ -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")
|
Loading…
Reference in a new issue