getting_started/first_2d_game/06.heads_up_display #69
Replies: 14 comments 23 replies
-
In the last part about "removing old creeps" the newest version of Godot now supports global and scene groups. |
Beta Was this translation helpful? Give feedback.
-
C# users must change the connections under the Node tab to C# nomenclature, not the default it provides you. Change these: _on_start_button_pressed to: OnStartButtonPressed or, if you've already created the script as guided, you can select the Pick button to the right of the text field when editing the connection, and then select the appropriate method. |
Beta Was this translation helpful? Give feedback.
-
why am i not able to connect start_game signal of HUD node to new_game() function of Main node? |
Beta Was this translation helpful? Give feedback.
-
when i am trying to connect start_game signal of HUD node to new_game() function of Main node , I can't find the function new_game() in the options in the pop? |
Beta Was this translation helpful? Give feedback.
-
When I create a new group named "mobs" and use the code to clear all mobs, the Player and the HUD are also cleared. I assume the problem is that they are being included the in mobs group, but I have no idea how this group is supposed to know what is inside it anyway. How do I make sure the "mobs" group only contains instances of Mob? |
Beta Was this translation helpful? Give feedback.
-
Something breaking down between my _on_start_button_pressed and new_game, not sure what I'm missing. Tried disconnecting and reconnecting, but no change. new_game triggers fine if I have _ready call it. I'm seeing the debug print I added for the start button press. Best I can tell is the signal isn't being emitted. Anyone have an idea what's breaking down? Here's my _on_start_button_pressed: func _on_start_button_pressed():
print("Debug: Start Button pressed")
$StartButton.hide()
start_game.emit Here's my new_game: func new_game():
print("Debug: new_game called")
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.update_score(score)
$HUD.show_message("Get Ready") |
Beta Was this translation helpful? Give feedback.
-
I was crashing with an error that it couldn't find "$HUD.update_score(score)" and I had to poke around for the solution. Mine was named #hud and not #HUD. Case matters apparently, because I fixed the case and the game works fine. Hope that makes sense and helps someone. |
Beta Was this translation helpful? Give feedback.
-
So I worked through this over a couple of days and I was a bit confused at the end because I realized that I never added my mob scene to the Main tree. So I was left wondering "how the f is this even connected?" Of course it was a bit simple to solve by simply going backwards. But I wonder if it would be useful to show the mob scene in the tree somehow. Basically to show its being used by Mobpath. Maybe this would be good for a small game like this, and would be problematic in a complicated scene. |
Beta Was this translation helpful? Give feedback.
-
Hi all, I have having an issue after pressing Start button. Error message: Attempt to call function 'start' in base 'null instance' on a null instance. There seems to be an issue with the message timer activation. 3 things were called onto the stack frames and the corresponding code below:
func show_message(text):
$Message.text = text
$Message.show()
$MessageTimer.start()
func new_game():
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.update_score(score)
$HUD.show_message("Get Ready")
get_tree().call_group("mobs", "queue_free")
func _on_start_button_pressed():
$StartButton.hide()
start_game.emit() Can anyone share where I went wrong? |
Beta Was this translation helpful? Give feedback.
-
The instructions say to extend HUD from CanvasLayer. But if I do I get this error: script inherits from native type ‘area2d’ so it cannot be instanced in object of type node Changing it to "extends Node" works - I found a similar question posed online too so I was surprised not to see a similar comment here. |
Beta Was this translation helpful? Give feedback.
-
Hello I am having some issues with my scripts breaking at the start_game.emit() portion of the code. I have added signal start_game to the top of the HUD.gd script, under extends CanvasLayer, and linked the start game signal from later in the hud.gd script func _on_start_button_pressed():
$StartButton.hide()
start_game.emit() to the new_game() function in the main.gd script func new_game():
score = 0
$Player.start($StartPosition.position)
$StartTimer.start()
$HUD.update_score(score)
$HUD.show_message("Get Ready")
get_tree().call_group("mobs", "queue_free") Despite seemingly following the instructions, when I press the start button the game crashes, and the debugger identifies the line with start_game.emit() as the point where the code breaks. Can anyone tell me what I am doing wrong? |
Beta Was this translation helpful? Give feedback.
-
I also had to start the $ScoreTimer.start()
$MobTimer.start() |
Beta Was this translation helpful? Give feedback.
-
I'm pretty sure I followed all the instructions but for some reason the score wont update. It merely stays at zero |
Beta Was this translation helpful? Give feedback.
-
The groups tab is not giving me the option create a new group. godot 4btw |
Beta Was this translation helpful? Give feedback.
-
getting_started/first_2d_game/06.heads_up_display
The final piece our game needs is a User Interface (UI) to display things like score, a "game over" message, and a restart button. Create a new scene, click the "Other Node" button and add a Canvas...
https://docs.godotengine.org/en/stable/getting_started/first_2d_game/06.heads_up_display.html
Beta Was this translation helpful? Give feedback.
All reactions