0 votes

Hello everyone, I want to show the button menu, if my ship is destroyed.

I have this but it doesn't show, but also can't display any errors:

func _ready():
    connect("pressed", self, "_on_pressed")
    attach("ship", "exit_tree", self, "_on_ship_exit_tree")
    pass 

func _on_pressed():
    get_tree().change_scene("res://stages/stage_menu.tscn") 
    pass

func _on_ship_exit_tree():
    $TextureButton/btn_menu.show()
    pass

Any help?

in Engine by (21 points)

What does the attach function do? I'm expecting it should do something similar to connect but I can't be certain, and I would say that it is the root cause of your problem, either that or your shit is never leaving the tree.

Also, you do not need to use pass at the end of every method. It is just a keyword used to enable empty methods.

1 Answer

0 votes

Try use "visible".

func _ready():
    $TextureButton.visible = false
    $TextureButton..disabled = true #prevent press
func _on_ship_destroy():
    $TextureButton.visible = true
    $TextureButton..disabled = false
    # some other func - score, particles ...
by (76 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.