I have a simple shoot'em up in space. When enemies collide with missiles, they explode and disappear. I also send a signal (enemyHit) to HUD to update and display the score. I have declared the signal, connected it to a function in HUD, yet, the function does not get called (the 2 print methods in the function are for debugging purposes). Thanks for any help.
The missile code:
extends RigidBody2D
signal enemyHit
export (PackedScene) var Explosion
func _on_VisibilityNotifier2D_screen_exited():
queue_free()
func _on_Missiles_body_entered(body):
if !body.is_in_group("player"):
emit_signal("enemyHit")
var explosion_instance = Explosion.instance()
explosion_instance.position = get_global_position()
get_tree().get_root().add_child(explosion_instance)
queue_free()
$CollisionShape2D.set_deferred("disabled", true)
The HUD code:
extends CanvasLayer
var score = 0
func _ready():
score = 0
func _on_Missiles_enemyHit():
score += 1
print (str(score))
print ("function called")
$ScoreLabel.text = str(score)