Skip to content

Commit 0f03d05

Browse files
committed
fix: connect player hit signal to on_player_hit method
suggestion by: Yarwin.
1 parent 50945d5 commit 0f03d05

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

squash-the-creeps/godot/main.tscn

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,5 +131,4 @@ grow_horizontal = 2
131131
grow_vertical = 2
132132
text = "Press enter retry"
133133

134-
[connection signal="hit" from="Player" to="." method="on_player_hit"]
135134
[connection signal="timeout" from="MobTimer" to="." method="on_mob_timer_timeout"]

squash-the-creeps/rust/src/main_scene.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use crate::mob;
22
use crate::player;
3+
use crate::player::Player;
34
use crate::scorelabel::UserInterface;
45

56
use godot::classes::{ColorRect, InputEvent, PathFollow3D, Timer};
@@ -27,6 +28,12 @@ impl INode for MainScene {
2728
self.base()
2829
.get_node_as::<ColorRect>("UserInterface/Retry")
2930
.hide();
31+
32+
self.base()
33+
.get_node_as::<Player>("Player")
34+
.signals()
35+
.hit()
36+
.connect_other(&self.to_gd(), Self::on_player_hit);
3037
}
3138
fn unhandled_input(&mut self, event: Gd<InputEvent>) {
3239
if event.is_action_pressed("ui_accept")

0 commit comments

Comments
 (0)