changed menu navigation
This commit is contained in:
parent
9b890c6bd2
commit
033718351e
7 changed files with 248 additions and 33 deletions
66
gmtk_2024/scripts/level_completed_control.gd
Normal file
66
gmtk_2024/scripts/level_completed_control.gd
Normal file
|
@ -0,0 +1,66 @@
|
|||
extends Control
|
||||
|
||||
var credits_text = """
|
||||
CONGRATULATIONS
|
||||
THIS SECTOR IS NOW INFECTED
|
||||
YOU NOW HAVE ACCESS TO THE NEXT SECTION
|
||||
|
||||
"""
|
||||
|
||||
var current_text = ""
|
||||
var char_index = 0
|
||||
var typing_speed = 0.05 # Normale Tippgeschwindigkeit
|
||||
var fast_typing_speed = 0.01 # Schnellere Tippgeschwindigkeit
|
||||
var is_fast_typing = false # Statusvariable für schnelleres Tippen
|
||||
|
||||
# Zum Überprüfen eines Doppelklicks
|
||||
var last_click_time = 0.0
|
||||
var double_click_time = 0.3 # Zeitfenster für Doppelklick in Sekunden
|
||||
|
||||
func _ready():
|
||||
_start_typing()
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
# Überprüfe, ob eine Taste oder Maustaste gedrückt gehalten wird
|
||||
if Input.is_action_pressed("ui_accept") or Input.is_action_pressed("ui_accept"):
|
||||
if get_time_since_last_click() <= double_click_time:
|
||||
_show_full_text()
|
||||
else:
|
||||
is_fast_typing = true
|
||||
else:
|
||||
is_fast_typing = false
|
||||
|
||||
typing_speed = fast_typing_speed if is_fast_typing else 0.05
|
||||
|
||||
func _start_typing() -> void:
|
||||
current_text = ""
|
||||
char_index = 0
|
||||
_update_text()
|
||||
|
||||
func _update_text() -> void:
|
||||
if char_index < credits_text.length():
|
||||
current_text += credits_text[char_index]
|
||||
$VBoxContainer/Label.text = current_text
|
||||
char_index += 1
|
||||
await get_tree().create_timer(typing_speed).timeout
|
||||
_update_text()
|
||||
else:
|
||||
_show_menu_options()
|
||||
|
||||
func _show_menu_options() -> void:
|
||||
$VBoxContainer/BackToMenu.visible = true
|
||||
|
||||
func _return_to_main_menu() -> void:
|
||||
get_tree().change_scene_to_file("res://menu/level_menu/level_select.tscn")
|
||||
|
||||
func _show_full_text() -> void:
|
||||
current_text = credits_text
|
||||
$VBoxContainer/Label.text = current_text
|
||||
char_index = credits_text.length()
|
||||
_show_menu_options()
|
||||
|
||||
func get_time_since_last_click() -> float:
|
||||
var current_time = Time.get_ticks_msec() / 1000.0 # Zeit in Sekunden
|
||||
var time_since_last_click = current_time - last_click_time
|
||||
last_click_time = current_time
|
||||
return time_since_last_click
|
Loading…
Add table
Add a link
Reference in a new issue