diff --git a/godot/scenes/Joke Button.gd b/godot/scenes/Joke Button.gd index 32e7a3d..51d8837 100644 --- a/godot/scenes/Joke Button.gd +++ b/godot/scenes/Joke Button.gd @@ -1,6 +1,6 @@ extends Node2D -signal button_pressed +signal button_pressed(joke) @export_enum("joke_button_1", "joke_button_2", "joke_button_3") var action: String @@ -16,4 +16,4 @@ func _ready(): # Called every frame. 'delta' is the elapsed time since the previous frame. func _process(delta): if Input.is_action_just_pressed(action): - emit_signal("button_pressed", current_joke) + button_pressed.emit(current_joke) diff --git a/godot/scenes/Tim.gd b/godot/scenes/Tim.gd index c307efc..968cdf5 100644 --- a/godot/scenes/Tim.gd +++ b/godot/scenes/Tim.gd @@ -21,3 +21,7 @@ func _process(delta): global_position += Vector2.LEFT * delta * move_speed if global_position.x < boundary.get_most_left_position(): global_position = Vector2(boundary.get_most_left_position(), global_position.y) + + +func _on_joke_button_button_pressed(joke): + pass # Replace with function body. diff --git a/godot/scenes/stage.tscn b/godot/scenes/stage.tscn index fcd0ef1..70fd8b6 100644 --- a/godot/scenes/stage.tscn +++ b/godot/scenes/stage.tscn @@ -34,12 +34,14 @@ position = Vector2(0, -25) [node name="Joke Button 1" type="Node2D" parent="Tim/Joke Buttons"] script = ExtResource("3_opgtx") +action = "joke_button_1" [node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 1"] texture = SubResource("PlaceholderTexture2D_k2q2d") [node name="Joke Button 2" type="Node2D" parent="Tim/Joke Buttons"] script = ExtResource("3_opgtx") +action = "joke_button_2" [node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 2"] position = Vector2(-150, -50) @@ -47,6 +49,7 @@ texture = SubResource("PlaceholderTexture2D_k2q2d") [node name="Joke Button 3" type="Node2D" parent="Tim/Joke Buttons"] script = ExtResource("3_opgtx") +action = "joke_button_3" [node name="Sprite2D" type="Sprite2D" parent="Tim/Joke Buttons/Joke Button 3"] position = Vector2(150, -50) @@ -54,3 +57,7 @@ texture = SubResource("PlaceholderTexture2D_k2q2d") [node name="Boundary" type="Node2D" parent="."] script = ExtResource("2_8p6ir") + +[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 1" to="Tim" method="_on_joke_button_button_pressed"] +[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 2" to="Tim" method="_on_joke_button_button_pressed"] +[connection signal="button_pressed" from="Tim/Joke Buttons/Joke Button 3" to="Tim" method="_on_joke_button_button_pressed"] diff --git a/godot/types/joke.gd b/godot/types/joke.gd index 16ae7dd..a31b854 100644 --- a/godot/types/joke.gd +++ b/godot/types/joke.gd @@ -6,5 +6,7 @@ enum JokeType { Joke3 } +var type: JokeType + func _init(type): self.type = type