Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Rayu |
I don’t know what my problem here is. No issues in playing the Game but somehow this doens’t work.
I have a Scene change event, whenever it happends the Enemies on the Screen should disappear. I tried but failed.
Enemy2 Script: (because if Player1 is pressed 2,3,4 should disappear)
signal level_complete1
func _ready() -> void:
$Enemy2sprite.connect("Player1_pressed", self, "_on_Player1_pressed")
I’ve connected the Player1_pressed signal in this Script again, it is also connected in a different function in the main script. Can you use this signal in more than 1 func? it should be right?
func hide_for_time(t):
visible = false
yield(get_tree().create_timer(t), "timeout")
visible = true
func _on_Player1_pressed():
emit_signal("level_complete1")
then the signal goes to the Main Script: (right?)
var Enemy2lvl = preload("res://Enemy/Enemy2.tscn")
func _on_wanted1_pressed():
Enemy2lvl.connect("level_complete1", self, "_on_level_complete1")
func _on_level_complete1():
get_node("Enemy2sprite").hide_for_time(2.0)
but the Enemy2sprite is not in the Main Scene, it’s in the Enemy Scene, but i used a signal shouldn’t it work?
i have also tried this:
func _on_level_complete1():
Enemy2lvl.hide_for_time(2.0)