interpolate popup scale
This commit is contained in:
parent
6b2587a90d
commit
774ad1b565
|
@ -62,7 +62,7 @@ func _on_Taquin_state_changed(previous, new):
|
|||
pass
|
||||
|
||||
func _on_New_game_pressed():
|
||||
$NewGamePanel.popup_centered(OS.window_size * 0.9)
|
||||
$NewGamePanel.popup_centered_ratio($NewGamePanel.window_scale_factor)
|
||||
|
||||
func _on_NewGamePanel_about_to_show():
|
||||
$HSplitContainer/Taquin.set_process_input(false)
|
||||
|
|
|
@ -6,8 +6,11 @@ signal start_triggered(config)
|
|||
|
||||
const pref_path = "user://preferences.cfg"
|
||||
|
||||
export var window_scale_factor = 0.9 # how big the popup will be compared to screen
|
||||
|
||||
var preferences = ConfigFile.new()
|
||||
var fade_duration = 0.2
|
||||
var fade_scale_factor = 0.9
|
||||
|
||||
onready var tween = $Tween
|
||||
|
||||
|
@ -19,6 +22,9 @@ func _ready():
|
|||
|
||||
func fade_out():
|
||||
tween.remove_all()
|
||||
tween.interpolate_property(self, "rect_scale", Vector2(1.0, 1.0), Vector2(fade_scale_factor, fade_scale_factor), fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
var scaled_center_position: Vector2 = (OS.window_size - (rect_size * fade_scale_factor)) / 2
|
||||
tween.interpolate_property(self, "rect_position", rect_position, scaled_center_position, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
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()
|
||||
|
@ -58,6 +64,11 @@ func _on_NewGamePanel_about_to_show():
|
|||
|
||||
$Panel/Start.grab_focus()
|
||||
|
||||
tween.interpolate_property(self, "modulate:a", 0.0, 1.0, 0.3, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
var size = OS.window_size * window_scale_factor
|
||||
tween.interpolate_property(self, "rect_scale", Vector2(fade_scale_factor, fade_scale_factor), Vector2(1.0, 1.0), fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
var original_position: Vector2 = (OS.window_size - size) / 2
|
||||
var scaled_center_position: Vector2 = (OS.window_size - (size * fade_scale_factor)) / 2
|
||||
tween.interpolate_property(self, "rect_position", scaled_center_position, original_position, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.interpolate_property(self, "modulate:a", 0.0, 1.0, fade_duration, Tween.TRANS_LINEAR, Tween.EASE_IN)
|
||||
tween.start()
|
||||
|
||||
|
|
Loading…
Reference in a new issue