ft: switch to click movement

This commit is contained in:
2026-03-07 14:33:22 +01:00
parent a59255d9d6
commit 01f1b52086
9 changed files with 50 additions and 19 deletions

View File

@@ -3,6 +3,7 @@ class_name FoodMolecular
@onready var collision: Area2D = $Collision
@onready var sprite: AnimatedSprite2D = $Collision/Sprite
@onready var player = get_tree().get_first_node_in_group("player") # FIXME: this is not v efficient; global resource? or at least per Stage.
func _ready() -> void:
sprite.play()
@@ -30,3 +31,10 @@ func apply_effect(consumer: Node2D) -> void:
if consumer.has_method("collect_resource"): # TODO: Define a "consumer" group instead?
consumer.collect_resource(val) # val is from parent (default 1), override if required
# TODO: *Some cool effect here*
# FIXME: position tracking inaccurate?
func _on_collision_input_event(viewport: Node, event: InputEvent, shape_idx: int) -> void:
if event is InputEventMouseButton and event.button_index == MOUSE_BUTTON_LEFT and event.pressed:
if player:
player.target = self.collision

View File

@@ -53,9 +53,6 @@ radius = 5.0
[node name="FoodMol" type="Node2D" unique_id=742430243]
script = ExtResource("1_0vfbj")
val = null
food_name = null
flow_carry_speed = null
metadata/_custom_type_script = "uid://cayxffay17o0u"
[node name="Collision" type="Area2D" parent="." unique_id=927700818]
@@ -78,3 +75,4 @@ script = ExtResource("3_8lhj0")
metadata/_custom_type_script = "uid://bvbc0n0pslq7p"
[connection signal="body_entered" from="Collision" to="." method="_on_body_entered"]
[connection signal="input_event" from="Collision" to="." method="_on_collision_input_event"]