Attempts at fixing signals
This commit is contained in:
parent
e4f87366d0
commit
7a2f860519
|
@ -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")
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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={
|
||||
|
|
Loading…
Reference in New Issue
Block a user