Implement joke button signaling
This commit is contained in:
parent
515c9eefc7
commit
f224391f30
|
@ -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)
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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"]
|
||||
|
|
|
@ -6,5 +6,7 @@ enum JokeType {
|
|||
Joke3
|
||||
}
|
||||
|
||||
var type: JokeType
|
||||
|
||||
func _init(type):
|
||||
self.type = type
|
||||
|
|
Loading…
Reference in New Issue