Attempts at fixing signals

This commit is contained in:
theskywinds 2025-05-18 15:40:05 +02:00
parent e4f87366d0
commit 7a2f860519
3 changed files with 14 additions and 7 deletions

View File

@ -1,12 +1,14 @@
extends Area2D
signal Pickup
signal _picked_up
func _ready():
add_to_group("crystals")
print("ready")
func _on_body_entered(body: Node2D) -> void:
emit_signal("Pickup")
add_user_signal("_picked_up")
emit_signal("_picked_up")
self.queue_free()
print("meow")

View File

@ -1,12 +1,13 @@
extends CharacterBody2D
const SPEED = 3.0
#func _ready() -> void:
# var collectable = get_node("collectableCrystal")
# collectable.connect("pickup",self,"collect")
func _ready() -> void:
var crystals = get_tree().get_nodes_in_group("crystals")
for crystal in crystals:
crystal.connect("_picked_up", Callable(self, "collect"))
#func collect():
# print("something")
func collect():
print("something")
func _physics_process(delta: float) -> void:
# Get the input direction and handle the movement/deceleration.

View File

@ -14,6 +14,10 @@ config/name="The crystaline adventure"
run/main_scene="uid://bj1x4w8ek53u1"
config/features=PackedStringArray("4.4", "Forward Plus")
[global_group]
crystals=""
[input]
moveLeft={