Files

44 lines
918 B
GDScript

extends CanvasLayer
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
update_progress_bar(80)
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
pass
func update_progress_bar(value: float):
var start_value = $ProgressBar.value
var percent = 0
while percent < 100:
var ease = expo_ease_in_out(start_value, value, percent)
$ProgressBar.value = ease
percent += 1
await get_tree().create_timer(0.05).timeout
func expo_ease_in_out(start: float, end: float, percent: int) -> float:
var t: float = clamp(float(percent) / 100.0, 0, 1.0)
var change: float = end - start
if t == 0:
return start
if t == 1.0:
return end
if t < 0.5:
return change / 2 * pow(2, 20 * t - 10) + start
else:
return change / 2 * (-pow(2, -20 * t + 10) + 2) + start