From 9199cd7a606099bace6780dff4ce807856b839de Mon Sep 17 00:00:00 2001
From: Jannik Rosendahl <jannik.rosendahl@me.com>
Date: Thu, 9 Dec 2021 16:54:32 +0100
Subject: [PATCH] fix fireball sprite mirror

---
 src/actors/player/FireBall.gd   | 8 ++++++++
 src/actors/player/FireBall.tscn | 4 ++--
 src/actors/player/Player.gd     | 2 +-
 3 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/src/actors/player/FireBall.gd b/src/actors/player/FireBall.gd
index ca538c9..e88a9e8 100755
--- a/src/actors/player/FireBall.gd
+++ b/src/actors/player/FireBall.gd
@@ -26,3 +26,11 @@ func _on_Area2D_body_entered(body : Node):
 		queue_free()
 	#print("collided with " + str(body.name) + " - " + str(body.get_class()) + " - " +  str(body.get_groups()))
 
+func set_direction(dir: Vector2):
+	direction = dir
+	print(dir)
+	if dir.x < 0:
+		print("flip")
+		$Sprite.flip_v = true
+		$Sprite.offset.y = 25
+	
diff --git a/src/actors/player/FireBall.tscn b/src/actors/player/FireBall.tscn
index d00b378..3d88761 100755
--- a/src/actors/player/FireBall.tscn
+++ b/src/actors/player/FireBall.tscn
@@ -12,7 +12,7 @@ collision_mask = 24
 script = ExtResource( 1 )
 
 [node name="Sprite" type="Sprite" parent="."]
-position = Vector2( 0, -18 )
+position = Vector2( -12, -18 )
 rotation = -1.57079
 texture = ExtResource( 2 )
 
@@ -21,7 +21,7 @@ collision_layer = 5
 collision_mask = 24
 
 [node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
-position = Vector2( 12, -18 )
+position = Vector2( 0, -18 )
 shape = SubResource( 2 )
 
 [connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
diff --git a/src/actors/player/Player.gd b/src/actors/player/Player.gd
index 2b2c257..a9d4532 100755
--- a/src/actors/player/Player.gd
+++ b/src/actors/player/Player.gd
@@ -211,7 +211,7 @@ func attack_process():
 		if attack_state == ATTACK_STATES.RANGED:
 			var b = FireBall.instance()
 			b.position = self.position
-			b.direction = self.last_look_direction
+			b.set_direction(self.last_look_direction) 
 			get_tree().current_scene.add_child(b)
 		if attack_state == ATTACK_STATES.MELEE:
 			print("melee")
-- 
GitLab