This commit is contained in:
Torsten 2024-12-22 14:02:54 +01:00
parent 1e22d28754
commit 6b926d3afe
126 changed files with 128562 additions and 104297 deletions

View file

@ -0,0 +1,81 @@
ProjectProject Settings...Input Map
Define action + button there
![[Pasted image 20240713073756.png]]
Next, select a button, and open Shortcut section
![[Pasted image 20240713073933.png]]
Click the <empty> Shortcut field, then select New Shortcut
The `Shortcut` resource takes an array of inputs as its data because in case you'd want to trigger the same button with multiple different inputs or input actions.
sadfs
![[Pasted image 20240713074212.png]]
![[Pasted image 20240713074345.png]]
Click on the created InputEventAction to expand it.
![[Pasted image 20240713080012.png]]
Set action to advance_text ( The action we created in the very first screenshot of this page)
![[Pasted image 20240713080125.png]]
Now all input defined for advance_text action will trigger the button.
Disabling button until tween finished
```python
func show_text() -> void:
# We first extract data for the current dialogue item and apply it to the UI
# elements.
# ...
next_button.disabled = true
tween.finished.connect(func() -> void:
next_button.disabled = false
)
```
Note to self: It seems to be possible to connect an event to more than 1 function. Here the full function from the tutorial. Note the tween.connect re-use
```python
func show_text() -> void:
# We first extract data for the current dialogue item and apply it to the UI
# elements.
var current_item := dialogue_items[current_item_index]
rich_text_label.text = current_item["text"]
expression_texture_rect.texture = current_item["expression"]
body.texture = current_item["character"]
# We then hide the text and animate it appearing.
rich_text_label.visible_ratio = 0.0
var tween := create_tween()
var text_appearing_duration: float = current_item["text"].length() / 30.0
tween.tween_property(rich_text_label, "visible_ratio", 1.0, text_appearing_duration)
# We randomize the audio playback's start time to make it sound different
# every time and play the sound until the text finishes displaying.
var sound_max_length := audio_stream_player.stream.get_length() - text_appearing_duration
var sound_start_position := randf() * sound_max_length
audio_stream_player.play(sound_start_position)
tween.finished.connect(audio_stream_player.stop)
# We animate the character sliding in.
slide_in()
# Finally, we disable the next button until the text finishes displaying.
next_button.disabled = true
tween.finished.connect(func() -> void:
next_button.disabled = false
)
```