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 extends Area2D
signal Pickup signal _picked_up
func _ready(): func _ready():
add_to_group("crystals")
print("ready") print("ready")
func _on_body_entered(body: Node2D) -> void: func _on_body_entered(body: Node2D) -> void:
emit_signal("Pickup") add_user_signal("_picked_up")
emit_signal("_picked_up")
self.queue_free() self.queue_free()
print("meow") print("meow")

View File

@ -1,12 +1,13 @@
extends CharacterBody2D extends CharacterBody2D
const SPEED = 3.0 const SPEED = 3.0
#func _ready() -> void: func _ready() -> void:
# var collectable = get_node("collectableCrystal") var crystals = get_tree().get_nodes_in_group("crystals")
# collectable.connect("pickup",self,"collect") for crystal in crystals:
crystal.connect("_picked_up", Callable(self, "collect"))
#func collect(): func collect():
# print("something") print("something")
func _physics_process(delta: float) -> void: func _physics_process(delta: float) -> void:
# Get the input direction and handle the movement/deceleration. # 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" run/main_scene="uid://bj1x4w8ek53u1"
config/features=PackedStringArray("4.4", "Forward Plus") config/features=PackedStringArray("4.4", "Forward Plus")
[global_group]
crystals=""
[input] [input]
moveLeft={ moveLeft={