0 votes

I'm doing the Dodge the Creeps tutorial in the Godot documentation.

In the Connecting HUD to Main section, it says "In the Node tab, connect the HUD’s startgame signal to the newgame() function."

The "main.gd" script shows as an option to connect to, so I selected that, since the new_game() function is a part of main.gd.

Connecting it makes a new function inside of main.gd:

func _on_HUD_start_game() -> void:
pass # Replace with function body.

So, the part I can't figure out is, how do I connect it to the other function, newgame, which is also inside of main.gd? newgame is already in there as:

func new_game():
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()

The documentation says "In the Node tab, connect the HUD’s startgame signal to the newgame() function.", but I can only get as far as placing it in the same main.gd script that new_game is in.

in Engine by (15 points)

1 Answer

0 votes
Best answer

Type "new_game" in the "Method in Node" box of the connect dialog.

This was demonstrated a few steps earlier when connect the player's hit signal to game_over():

https://docs.godotengine.org/en/latest/getting_started/step_by_step/your_first_game.html#main-script

by (20,355 points)

Thanks. :)

I did that part the other day, so it wasn't fresh in my memory.

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 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 webmaster@godotengine.org with your username.