Add an optional extra RESET step in Tween demo (#892)

This commit is contained in:
Tomek
2023-03-29 18:35:26 +02:00
committed by GitHub
parent 956875c306
commit 4bbf04129a
2 changed files with 18 additions and 1 deletions

View File

@@ -121,10 +121,15 @@ func start_animation():
tween.tween_callback(icon.show)
tween.tween_callback(icon.set_self_modulate.bind(Color.WHITE))
# RESET step
if %Reset.button_pressed:
tween.tween_callback(reset.bind(true))
func do_countdown(v):
countdown_label.text = str(v)
func reset():
func reset(soft := false):
icon.position = icon_start_position
icon.self_modulate = Color.WHITE
icon.rotation = 0
@@ -132,6 +137,10 @@ func reset():
icon.show()
countdown_label.hide()
if soft:
# Only reset properties.
return
if tween:
tween.kill()
tween = null

View File

@@ -68,6 +68,14 @@ unique_name_in_owner = true
layout_mode = 2
text = "Infinite?"
[node name="Reset" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
tooltip_text = "If enabled, the Tween will take an extra step to ensure
that all properties are restored to their initial value."
button_pressed = true
text = "Reset Between Loops?"
[node name="Button" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
layout_mode = 2
text = "Start Animation"