fade-in/out popup
This commit is contained in:
parent
c6b9a06419
commit
6b2587a90d
2 changed files with 20 additions and 2 deletions
|
@ -7,6 +7,9 @@ signal start_triggered(config)
|
|||
const pref_path = "user://preferences.cfg"
|
||||
|
||||
var preferences = ConfigFile.new()
|
||||
var fade_duration = 0.2
|
||||
|
||||
onready var tween = $Tween
|
||||
|
||||
func _init():
|
||||
var err = preferences.load(pref_path)
|
||||
|
@ -14,8 +17,14 @@ func _init():
|
|||
func _ready():
|
||||
pass
|
||||
|
||||
func fade_out():
|
||||
tween.remove_all()
|
||||
tween.interpolate_property(self, "modulate:a", 1.0, 0.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_callback(self, fade_duration, "hide")
|
||||
tween.start()
|
||||
|
||||
func _on_Cancel_pressed():
|
||||
self.hide()
|
||||
fade_out()
|
||||
|
||||
func _on_Start_pressed():
|
||||
if $Panel/HBoxContainer/Easy.pressed:
|
||||
|
@ -28,7 +37,7 @@ func _on_Start_pressed():
|
|||
preferences.save(pref_path)
|
||||
|
||||
emit_signal("start_triggered", preferences)
|
||||
self.hide()
|
||||
fade_out()
|
||||
|
||||
func _on_NewGamePanel_about_to_show():
|
||||
$Panel/HBoxContainer/Easy.pressed = false
|
||||
|
@ -48,3 +57,7 @@ func _on_NewGamePanel_about_to_show():
|
|||
$Panel/HBoxContainer/Normal.pressed = true
|
||||
|
||||
$Panel/Start.grab_focus()
|
||||
|
||||
tween.interpolate_property(self, "modulate:a", 0.0, 1.0, 0.3, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.start()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue