New Tween demo (#803)

This commit is contained in:
Tomek
2022-12-17 23:44:08 +01:00
committed by GitHub
parent 35f9517ea8
commit 4eb852ac78
8 changed files with 594 additions and 524 deletions

View File

@@ -4,9 +4,7 @@ A demo showing advanced tween usage.
Language: GDScript
Renderer: GLES 2
Check out this demo on the asset library: https://godotengine.org/asset-library/asset/146
Renderer: Vulkan
## Screenshots

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/godot.png-5e0da45ed3d6786d5794553e04f58a8c.stex"
type="CompressedTexture2D"
uid="uid://bqpyg61et07pf"
path="res://.godot/imported/godot.png-5e0da45ed3d6786d5794553e04f58a8c.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,24 @@ metadata={
[deps]
source_file="res://godot.png"
dest_files=["res://.godot/imported/godot.png-5e0da45ed3d6786d5794553e04f58a8c.stex"]
dest_files=["res://.godot/imported/godot.png-5e0da45ed3d6786d5794553e04f58a8c.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,8 +1,9 @@
[remap]
importer="texture"
type="StreamTexture2D"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"
type="CompressedTexture2D"
uid="uid://bighifexsnokp"
path="res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"
metadata={
"vram_texture": false
}
@@ -10,26 +11,24 @@ metadata={
[deps]
source_file="res://icon.png"
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.stex"]
dest_files=["res://.godot/imported/icon.png-487276ed1e3a0c39cad0279d744ee560.ctex"]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/hdr_compression=1
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=true
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
process/normal_map_invert_y=false
stream=false
size_limit=0
detect_3d=true
svg/scale=1.0
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1

View File

@@ -1,154 +1,184 @@
extends Control
extends Node
const trans_list = ["Linear", "Sine", "Quint", "Quart", "Quad", "Expo", "Elastic", "Cubic", "Circ", "Bounce", "Back"]
const eases_list = ["In", "Out", "InOut", "OutIn"]
const modes_list = ["Move", "Color", "Scale", "Rotate", "Callback", "Follow", "Repeat", "Pause"]
@onready var icon: Sprite2D = %Icon
@onready var icon_start_position = icon.position
var current_trans = Tween.TRANS_LINEAR
var current_ease = Tween.EASE_IN
@onready var countdown_label = %CountdownLabel
@onready var path: Path2D = $Path2D
@onready var progress = %Progress
@onready var tween = $Tween
@onready var trans_vbox = $Controls/Transitions
@onready var eases_vbox = $Controls/Eases
@onready var modes_vbox = $Controls/Modes
@onready var timeline = $Top/Timeline
@onready var color_from_picker = $Controls/ColorFrom/ColorPicker
@onready var color_to_picker = $Controls/ColorTo/ColorPicker
@onready var area_label = $Top/Area3D/RichTextLabel
@onready var sprite = $Top/Area3D/Sprite2D
@onready var follow = $Top/Area3D/Follow
@onready var follow_2 = $Top/Area3D/Follow2
@onready var size = $Top/Area3D.get_size()
var tween: Tween
var sub_tween: Tween
@onready var move_mode = modes_vbox.get_node(^"Move")
@onready var color_mode = modes_vbox.get_node(^"Color")
@onready var scale_mode = modes_vbox.get_node(^"Scale")
@onready var rotate_mode = modes_vbox.get_node(^"Rotate")
@onready var callback_mode = modes_vbox.get_node(^"Callback")
@onready var follow_mode = modes_vbox.get_node(^"Follow")
@onready var repeat_mode = modes_vbox.get_node(^"Repeat")
@onready var paused_mode = modes_vbox.get_node(^"Pause")
func start_animation():
# Reset the icon to original state.
reset()
# Create the Tween. Also sets the initial animation speed.
# All methods that modify Tween will return the Tween, so you can chain them.
tween = create_tween().set_speed_scale(%SpeedSlider.value)
func _ready():
for index in range(trans_list.size()):
trans_vbox.get_node(trans_list[index]).connect(&"pressed", self.on_trans_changed, [index])
# Sets the amount of loops. 1 loop = 1 animation cycle, so e.g. 2 loops will play animation twice.
if %Infinite.button_pressed:
tween.set_loops() # Called without arguments, the Tween will loop infinitely.
else:
tween.set_loops(%Loops.value)
for index in range(eases_list.size()):
eases_vbox.get_node(eases_list[index]).connect(&"pressed", self.on_eases_changed, [index])
# Step 1
for index in range(modes_list.size()):
modes_vbox.get_node(modes_list[index]).connect(&"pressed", self.on_modes_changed, [index])
if is_step_enabled("MoveTo", 1.0):
# tween_*() methods return a Tweener object. Its methods can also be chained, but
# it's stored in a variable here for readability (chained lines tend to be long).
# Note the usage of ^"NodePath". A regular "String" is accepted too, but it's very slightly slower.
var tweener = tween.tween_property(icon, ^"position", Vector2(400, 250), 1.0)
tweener.set_ease(%Ease1.selected)
tweener.set_trans(%Trans1.selected)
color_from_picker.set_pick_color(Color.RED)
color_to_picker.set_pick_color(Color.CYAN)
# Step 2
for node in [trans_vbox, eases_vbox, modes_vbox]:
node.get_child(1).set_pressed(true)
modes_vbox.get_node(^"Repeat").set_pressed(true)
if is_step_enabled("ColorRed", 1.0):
tween.tween_property(icon, ^"self_modulate", Color.RED, 1.0)
reset_tween()
# Step 3
if is_step_enabled("MoveRight", 1.0):
# as_relative() makes the value relative, so in this case it moves the icon
# 200 pixels from the previous position.
var tweener = tween.tween_property(icon, ^"position:x", 200.0, 1.0).as_relative()
tweener.set_ease(%Ease3.selected)
tweener.set_trans(%Trans3.selected)
if is_step_enabled("Roll", 0.0):
# parallel() makes the Tweener run in parallel to the previous one.
var tweener = tween.parallel().tween_property(icon, ^"rotation", TAU, 1.0)
tweener.set_ease(%Ease3.selected)
tweener.set_trans(%Trans3.selected)
func on_trans_changed(index):
for i in range(trans_list.size()):
var btn = trans_vbox.get_node(trans_list[i])
btn.set_pressed(i == index)
# Step 4
current_trans = index
reset_tween()
if is_step_enabled("MoveLeft", 1.0):
tween.tween_property(icon, ^"position", Vector2.LEFT * 200, 1.0).as_relative()
if is_step_enabled("Jump", 0.0):
# Jump has 2 substeps, so to make it properly parallel, it can be done in a sub-Tween.
# Here we are calling a lambda method that creates a sub-Tween.
# Any number of Tweens can animate a single object in the same time.
tween.parallel().tween_callback(func():
# Note that transition is set on Tween, but ease is set on Tweener.
# Values set on Tween will affect all Tweeners (as defaults) and values
# on Tweeners can override them.
sub_tween = create_tween().set_speed_scale(%SpeedSlider.value).set_trans(Tween.TRANS_SINE)
sub_tween.tween_property(icon, ^"position:y", -150.0, 0.5).as_relative().set_ease(Tween.EASE_OUT)
sub_tween.tween_property(icon, ^"position:y", 150.0, 0.5).as_relative().set_ease(Tween.EASE_IN)
)
# Step 5
func on_eases_changed(index):
for i in range(eases_list.size()):
var btn = eases_vbox.get_node(eases_list[i])
btn.set_pressed(i == index)
if is_step_enabled("Blink", 2.0):
# Loops are handy when creating some animations.
for i in 10:
tween.tween_callback(icon.hide).set_delay(0.1)
tween.tween_callback(icon.show).set_delay(0.1)
current_ease = index
reset_tween()
# Step 6
if is_step_enabled("Teleport", 0.5):
# Tweening a value with 0 duration makes it change instantly.
tween.tween_property(icon, ^"position", Vector2(325, 325), 0)
tween.tween_interval(0.5)
# Binds can be used for advanced callbacks.
tween.tween_callback(icon.set_position.bind(Vector2(680, 215)))
func on_modes_changed(index):
if modes_list[index] == "Pause":
if paused_mode.is_pressed():
tween.stop_all()
# Step 7
if is_step_enabled("Curve", 3.5):
# Method tweening is useful for animating values that can't be directly interpolated.
# It can be used for remapping and some very advanced animations.
# Here it's used for moving sprite along a path, using inline lambda function.
var tweener = tween.tween_method(func(v): icon.position = path.position + path.curve.sample_baked(v),
0.0, path.curve.get_baked_length(), 3.0).set_delay(0.5)
tweener.set_ease(%Ease7.selected)
tweener.set_trans(%Trans7.selected)
# Step 8
if is_step_enabled("Wait", 2.0):
# ...
tween.tween_interval(2)
# Step 9
if is_step_enabled("Countdown", 3.0):
tween.tween_callback(countdown_label.show)
tween.tween_method(do_countdown, 4, 1, 3)
tween.tween_callback(countdown_label.hide)
# Step 10
if is_step_enabled("Enlarge", 0.0):
tween.tween_property(icon, ^"scale", Vector2.ONE * 5, 0.5).set_trans(Tween.TRANS_ELASTIC).set_ease(Tween.EASE_OUT)
if is_step_enabled("Vanish", 1.0):
tween.parallel().tween_property(icon, ^"self_modulate:a", 0.0, 1.0)
if %Loops.value > 1 or %Infinite.button_pressed:
tween.tween_callback(icon.show)
tween.tween_callback(icon.set_self_modulate.bind(Color.WHITE))
func do_countdown(v):
countdown_label.text = str(v)
func reset():
icon.position = icon_start_position
icon.self_modulate = Color.WHITE
icon.rotation = 0
icon.scale = Vector2.ONE
icon.show()
countdown_label.hide()
if tween:
tween.kill()
tween = null
if sub_tween:
sub_tween.kill()
sub_tween = null
progress.max_value = 0
func is_step_enabled(step, expected_time):
var enabled = get_node("%" + step).button_pressed
if enabled:
progress.max_value += expected_time
return enabled
func pause_resume() -> void:
if tween and tween.is_valid():
if tween.is_running():
tween.pause()
else:
tween.resume_all()
else:
reset_tween()
tween.play()
if sub_tween and sub_tween.is_valid():
if sub_tween.is_running():
sub_tween.pause()
else:
sub_tween.play()
func _on_ColorPicker_color_changed(_color):
reset_tween()
func kill_tween() -> void:
if tween:
tween.kill()
if sub_tween:
sub_tween.kill()
func speed_changed(value: float) -> void:
if tween:
tween.set_speed_scale(value)
if sub_tween:
sub_tween.set_speed_scale(value)
%SpeedLabel.text = str("x", value)
func reset_tween():
var pos = tween.tell()
tween.reset_all()
tween.remove_all()
func inifnite_toggled(button_pressed: bool) -> void:
%Loops.editable = not button_pressed
if move_mode.is_pressed():
# The first line moves from the top left to the bottom right, while
# the second line moves backwards afterwards (there is a delay of 2).
# These are different (_method vs _property) only for the sake of
# showcasing interpolation of both methods and properties.
# The syntax is (object, method/property name, from value, to value,
# duration, transition type, ease type, delay), last 3 optional.
tween.interpolate_method(sprite, "set_position", Vector2.ZERO, size, 2, current_trans, current_ease)
tween.interpolate_property(sprite, "position", size, Vector2.ZERO, 2, current_trans, current_ease, 2)
if color_mode.is_pressed():
tween.interpolate_method(sprite, "set_modulate", color_from_picker.get_pick_color(), color_to_picker.get_pick_color(), 2, current_trans, current_ease)
tween.interpolate_property(sprite, "modulate", color_to_picker.get_pick_color(), color_from_picker.get_pick_color(), 2, current_trans, current_ease, 2)
else:
sprite.set_modulate(Color.WHITE)
if scale_mode.is_pressed():
tween.interpolate_method(sprite, "set_scale", Vector2(0.5, 0.5), Vector2(1.5, 1.5), 2, current_trans, current_ease)
tween.interpolate_property(sprite, "scale", Vector2(1.5, 1.5), Vector2(0.5, 0.5), 2, current_trans, current_ease, 2)
else:
sprite.set_scale(Vector2.ONE)
if rotate_mode.is_pressed():
tween.interpolate_method(sprite, "set_rotation_degrees", 0, 360, 2, current_trans, current_ease)
tween.interpolate_property(sprite, "rotation_degrees", 360, 0, 2, current_trans, current_ease, 2)
if callback_mode.is_pressed():
tween.interpolate_callback(self, 0.5, "on_callback", "0.5 seconds after")
tween.interpolate_callback(self, 0.2, "on_callback", "1.2 seconds after")
if follow_mode.is_pressed():
follow.show()
follow_2.show()
tween.follow_method(follow, "set_position", Vector2(0, size.y), sprite, "get_position", 2, current_trans, current_ease)
tween.targeting_method(follow, "set_position", sprite, "get_position", Vector2(0, size.y), 2, current_trans, current_ease, 2)
tween.targeting_property(follow_2, "position", sprite, "position", Vector2(size.x, 0), 2, current_trans, current_ease)
tween.follow_property(follow_2, "position", Vector2(size.x, 0), sprite, "position", 2, current_trans, current_ease, 2)
else:
follow.hide()
follow_2.hide()
tween.set_repeat(repeat_mode.is_pressed())
tween.start()
tween.seek(pos)
if paused_mode.is_pressed():
tween.stop_all()
func _on_Tween_tween_step(_object, _key, elapsed, _value):
var runtime = tween.get_runtime()
var ratio = 100 * (elapsed / runtime)
timeline.set_value(ratio)
func _on_Timeline_value_changed(value):
if not paused_mode.is_pressed():
func _process(delta: float) -> void:
if not tween or not tween.is_running():
return
var runtime = tween.get_runtime()
tween.seek(runtime * value / 100)
func on_callback(arg):
area_label.add_text("on_callback -> " + arg + "\n")
progress.value = tween.get_total_elapsed_time()

View File

@@ -1,388 +1,450 @@
[gd_scene load_steps=6 format=2]
[gd_scene load_steps=8 format=3 uid="uid://dath4f6h4tbmk"]
[ext_resource path="res://main.gd" type="Script" id=1]
[ext_resource path="res://godot.png" type="Texture2D" id=2]
[ext_resource path="res://noto_sans_ui_regular.ttf" type="FontData" id=3]
[ext_resource type="Script" path="res://main.gd" id="1"]
[ext_resource type="Texture2D" uid="uid://bqpyg61et07pf" path="res://godot.png" id="2_tapbf"]
[sub_resource type="Font" id=1]
font_data = ExtResource( 3 )
[sub_resource type="Gradient" id="Gradient_npp8a"]
offsets = PackedFloat32Array(0)
colors = PackedColorArray(0, 0, 0, 1)
[sub_resource type="Theme" id=2]
default_font = SubResource( 1 )
[sub_resource type="GradientTexture2D" id="GradientTexture2D_md057"]
gradient = SubResource("Gradient_npp8a")
width = 800
height = 10
[node name="Main" type="VBoxContainer"]
[sub_resource type="Gradient" id="Gradient_vuuif"]
offsets = PackedFloat32Array(0)
colors = PackedColorArray(0, 1, 0, 1)
[sub_resource type="GradientTexture2D" id="GradientTexture2D_35fte"]
gradient = SubResource("Gradient_vuuif")
width = 800
height = 10
[sub_resource type="Curve2D" id="Curve2D_7nae7"]
_data = {
"points": PackedVector2Array(-142, -129, 142, 129, 2, 2, 0, 0, 0, 0, 311, 5, 172, -42, -172, 42, 45, -130, 83, 25, -83, -25, -150, -7, -16, 28, 16, -28, -198, -75, 0, 0, 0, 0, -71, -132)
}
point_count = 6
[node name="TweenDemo" type="CanvasLayer"]
script = ExtResource("1")
metadata/_edit_lock_ = true
[node name="VBoxContainer" type="VBoxContainer" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
theme = SubResource( 2 )
grow_horizontal = 2
grow_vertical = 2
[node name="ColorRect" type="ColorRect" parent="VBoxContainer"]
layout_mode = 2
size_flags_vertical = 3
color = Color(0.027451, 0, 0.168627, 1)
[node name="PanelContainer" type="PanelContainer" parent="VBoxContainer"]
layout_mode = 2
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer"]
layout_mode = 2
[node name="HBoxContainer3" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
alignment = 1
script = ExtResource( 1 )
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Tween" type="Tween" parent="."]
repeat = true
playback/repeat = true
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
layout_mode = 2
text = "Loops"
[node name="Top" type="VBoxContainer" parent="."]
offset_left = 112.0
offset_right = 912.0
offset_bottom = 230.0
rect_min_size = Vector2(800, 230)
size_flags_horizontal = 6
alignment = 2
[node name="Area3D" type="Panel" parent="Top"]
offset_top = 18.0
offset_right = 800.0
offset_bottom = 178.0
rect_min_size = Vector2(800, 160)
__meta__ = {
"_edit_use_anchors_": false
}
[node name="RichTextLabel" type="RichTextLabel" parent="Top/Area3D"]
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -120.0
offset_top = -60.0
offset_right = 120.0
offset_bottom = 60.0
size_flags_horizontal = 2
size_flags_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Sprite2D" type="Sprite2D" parent="Top/Area3D"]
z_index = 1
texture = ExtResource( 2 )
[node name="Follow" type="Sprite2D" parent="Top/Area3D"]
position = Vector2(0, 160)
z_index = 1
texture = ExtResource( 2 )
[node name="Follow2" type="Sprite2D" parent="Top/Area3D"]
position = Vector2(800, 0)
z_index = 1
texture = ExtResource( 2 )
[node name="Timeline" type="HSlider" parent="Top"]
offset_top = 182.0
offset_right = 800.0
offset_bottom = 230.0
rect_min_size = Vector2(0, 48)
size_flags_horizontal = 3
[node name="Loops" type="SpinBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
min_value = 1.0
value = 1.0
ticks_on_borders = true
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Controls" type="HBoxContainer" parent="."]
offset_top = 234.0
offset_right = 1024.0
offset_bottom = 804.0
rect_min_size = Vector2(1000, 550)
custom_constants/separation = 20
[node name="Infinite" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
text = "Infinite?"
[node name="Button" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3"]
layout_mode = 2
text = "Start Animation"
[node name="HSeparator2" type="HSeparator" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HFlowContainer" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
theme_override_constants/separation = 16
alignment = 1
[node name="Modes" type="VBoxContainer" parent="Controls"]
offset_left = 37.0
offset_right = 110.0
offset_bottom = 383.0
rect_min_size = Vector2(70, 0)
size_flags_vertical = 0
custom_constants/separation = 16
[node name="VBoxContainer" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="ModesLabel" type="Label" parent="Controls/Modes"]
offset_right = 73.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "Modes"
align = 1
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer"]
layout_mode = 2
text = "Step 1"
horizontal_alignment = 1
[node name="Move" type="Button" parent="Controls/Modes"]
offset_top = 39.0
offset_right = 73.0
offset_bottom = 68.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "move"
[node name="MoveTo" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Move To"
[node name="Color" type="Button" parent="Controls/Modes"]
offset_top = 84.0
offset_right = 73.0
offset_bottom = 113.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "color"
[node name="Ease1" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
item_count = 4
selected = 0
popup/item_0/text = "In"
popup/item_0/id = 0
popup/item_1/text = "Out"
popup/item_1/id = 1
popup/item_2/text = "In/Out"
popup/item_2/id = 2
popup/item_3/text = "Out/In"
popup/item_3/id = 3
[node name="Scale" type="Button" parent="Controls/Modes"]
offset_top = 129.0
offset_right = 73.0
offset_bottom = 158.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "scale"
[node name="Trans1" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
item_count = 11
selected = 0
popup/item_0/text = "Linear"
popup/item_0/id = 2
popup/item_1/text = "Sine"
popup/item_1/id = 1
popup/item_2/text = "Quint"
popup/item_2/id = 2
popup/item_3/text = "Quart"
popup/item_3/id = 3
popup/item_4/text = "Quad"
popup/item_4/id = 4
popup/item_5/text = "Expo"
popup/item_5/id = 5
popup/item_6/text = "Elastic"
popup/item_6/id = 6
popup/item_7/text = "Cubic"
popup/item_7/id = 7
popup/item_8/text = "Circ"
popup/item_8/id = 8
popup/item_9/text = "Bounce"
popup/item_9/id = 9
popup/item_10/text = "Back"
popup/item_10/id = 10
[node name="Rotate" type="Button" parent="Controls/Modes"]
offset_top = 174.0
offset_right = 73.0
offset_bottom = 203.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "rotate"
[node name="VBoxContainer2" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Callback" type="Button" parent="Controls/Modes"]
offset_top = 219.0
offset_right = 73.0
offset_bottom = 248.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "callback"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer2"]
layout_mode = 2
text = "Step 2"
horizontal_alignment = 1
[node name="Follow" type="Button" parent="Controls/Modes"]
offset_top = 264.0
offset_right = 73.0
offset_bottom = 293.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "follow"
[node name="ColorRed" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer2"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Color Red"
[node name="Repeat" type="Button" parent="Controls/Modes"]
offset_top = 309.0
offset_right = 73.0
offset_bottom = 338.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "repeat"
[node name="VBoxContainer3" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Pause" type="Button" parent="Controls/Modes"]
offset_top = 354.0
offset_right = 73.0
offset_bottom = 383.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "pause"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer3"]
layout_mode = 2
text = "Step 3"
horizontal_alignment = 1
[node name="Transitions" type="VBoxContainer" parent="Controls"]
offset_left = 130.0
offset_right = 215.0
offset_bottom = 518.0
rect_min_size = Vector2(70, 0)
size_flags_vertical = 0
custom_constants/separation = 16
__meta__ = {
"_edit_use_anchors_": false
}
[node name="MoveRight" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Move Right"
[node name="TransLabel" type="Label" parent="Controls/Transitions"]
offset_right = 85.0
offset_bottom = 23.0
text = "Transitions"
align = 1
[node name="Roll" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Roll"
[node name="Linear" type="Button" parent="Controls/Transitions"]
offset_top = 39.0
offset_right = 85.0
offset_bottom = 68.0
size_flags_vertical = 2
toggle_mode = true
text = "linear"
[node name="Ease3" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
item_count = 4
selected = 0
popup/item_0/text = "In"
popup/item_0/id = 0
popup/item_1/text = "Out"
popup/item_1/id = 1
popup/item_2/text = "In/Out"
popup/item_2/id = 2
popup/item_3/text = "Out/In"
popup/item_3/id = 3
[node name="Sine" type="Button" parent="Controls/Transitions"]
offset_top = 84.0
offset_right = 85.0
offset_bottom = 113.0
size_flags_vertical = 2
toggle_mode = true
text = "sine"
[node name="Trans3" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer3"]
unique_name_in_owner = true
layout_mode = 2
item_count = 11
selected = 10
popup/item_0/text = "Linear"
popup/item_0/id = 2
popup/item_1/text = "Sine"
popup/item_1/id = 1
popup/item_2/text = "Quint"
popup/item_2/id = 2
popup/item_3/text = "Quart"
popup/item_3/id = 3
popup/item_4/text = "Quad"
popup/item_4/id = 4
popup/item_5/text = "Expo"
popup/item_5/id = 5
popup/item_6/text = "Elastic"
popup/item_6/id = 6
popup/item_7/text = "Cubic"
popup/item_7/id = 7
popup/item_8/text = "Circ"
popup/item_8/id = 8
popup/item_9/text = "Bounce"
popup/item_9/id = 9
popup/item_10/text = "Back"
popup/item_10/id = 10
[node name="Quint" type="Button" parent="Controls/Transitions"]
offset_top = 129.0
offset_right = 85.0
offset_bottom = 158.0
size_flags_vertical = 2
toggle_mode = true
text = "quint"
[node name="VBoxContainer4" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Quart" type="Button" parent="Controls/Transitions"]
offset_top = 174.0
offset_right = 85.0
offset_bottom = 203.0
size_flags_vertical = 2
toggle_mode = true
text = "quart"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer4"]
layout_mode = 2
text = "Step 4"
horizontal_alignment = 1
[node name="Quad" type="Button" parent="Controls/Transitions"]
offset_top = 219.0
offset_right = 85.0
offset_bottom = 248.0
size_flags_vertical = 2
toggle_mode = true
text = "quad"
[node name="MoveLeft" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer4"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Move Left"
[node name="Expo" type="Button" parent="Controls/Transitions"]
offset_top = 264.0
offset_right = 85.0
offset_bottom = 293.0
size_flags_vertical = 2
toggle_mode = true
text = "expo"
[node name="Jump" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer4"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Jump"
[node name="Elastic" type="Button" parent="Controls/Transitions"]
offset_top = 309.0
offset_right = 85.0
offset_bottom = 338.0
size_flags_vertical = 2
toggle_mode = true
text = "elastic"
[node name="VBoxContainer5" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Cubic" type="Button" parent="Controls/Transitions"]
offset_top = 354.0
offset_right = 85.0
offset_bottom = 383.0
size_flags_vertical = 2
toggle_mode = true
text = "cubic"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer5"]
layout_mode = 2
text = "Step 5"
horizontal_alignment = 1
[node name="Circ" type="Button" parent="Controls/Transitions"]
offset_top = 399.0
offset_right = 85.0
offset_bottom = 428.0
size_flags_vertical = 2
toggle_mode = true
text = "circ"
[node name="Blink" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer5"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Blink"
[node name="Bounce" type="Button" parent="Controls/Transitions"]
offset_top = 444.0
offset_right = 85.0
offset_bottom = 473.0
size_flags_vertical = 2
toggle_mode = true
text = "bounce"
[node name="VBoxContainer6" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Back" type="Button" parent="Controls/Transitions"]
offset_top = 489.0
offset_right = 85.0
offset_bottom = 518.0
size_flags_vertical = 2
toggle_mode = true
text = "back"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer6"]
layout_mode = 2
text = "Step 6"
horizontal_alignment = 1
[node name="Eases" type="VBoxContainer" parent="Controls"]
offset_left = 235.0
offset_right = 305.0
offset_bottom = 203.0
rect_min_size = Vector2(70, 0)
size_flags_vertical = 0
custom_constants/separation = 16
[node name="Teleport" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer6"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Teleport"
[node name="EasesLabel" type="Label" parent="Controls/Eases"]
offset_right = 70.0
offset_bottom = 23.0
size_flags_horizontal = 3
text = "Eases"
align = 1
[node name="VBoxContainer10" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="In" type="Button" parent="Controls/Eases"]
offset_top = 39.0
offset_right = 70.0
offset_bottom = 68.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "in"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer10"]
layout_mode = 2
text = "Step 7"
horizontal_alignment = 1
[node name="Out" type="Button" parent="Controls/Eases"]
offset_top = 84.0
offset_right = 70.0
offset_bottom = 113.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "out"
[node name="Curve" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer10"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Curve"
[node name="InOut" type="Button" parent="Controls/Eases"]
offset_top = 129.0
offset_right = 70.0
offset_bottom = 158.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "in_out"
[node name="Ease7" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer10"]
unique_name_in_owner = true
layout_mode = 2
item_count = 4
selected = 1
popup/item_0/text = "In"
popup/item_0/id = 0
popup/item_1/text = "Out"
popup/item_1/id = 1
popup/item_2/text = "In/Out"
popup/item_2/id = 2
popup/item_3/text = "Out/In"
popup/item_3/id = 3
[node name="OutIn" type="Button" parent="Controls/Eases"]
offset_top = 174.0
offset_right = 70.0
offset_bottom = 203.0
size_flags_horizontal = 3
size_flags_vertical = 2
toggle_mode = true
text = "out_in"
[node name="Trans7" type="OptionButton" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer10"]
unique_name_in_owner = true
layout_mode = 2
item_count = 11
selected = 9
popup/item_0/text = "Linear"
popup/item_0/id = 2
popup/item_1/text = "Sine"
popup/item_1/id = 1
popup/item_2/text = "Quint"
popup/item_2/id = 2
popup/item_3/text = "Quart"
popup/item_3/id = 3
popup/item_4/text = "Quad"
popup/item_4/id = 4
popup/item_5/text = "Expo"
popup/item_5/id = 5
popup/item_6/text = "Elastic"
popup/item_6/id = 6
popup/item_7/text = "Cubic"
popup/item_7/id = 7
popup/item_8/text = "Circ"
popup/item_8/id = 8
popup/item_9/text = "Bounce"
popup/item_9/id = 9
popup/item_10/text = "Back"
popup/item_10/id = 10
[node name="ColorFrom" type="VBoxContainer" parent="Controls"]
offset_left = 325.0
offset_right = 646.0
offset_bottom = 570.0
rect_min_size = Vector2(320, 570)
size_flags_vertical = 0
[node name="VBoxContainer9" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Controls/ColorFrom"]
offset_right = 89.0
offset_bottom = 23.0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Color From:"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer9"]
layout_mode = 2
text = "Step 8"
horizontal_alignment = 1
[node name="ColorPicker" type="ColorPicker" parent="Controls/ColorFrom"]
offset_top = 27.0
offset_right = 321.0
offset_bottom = 539.0
size_flags_horizontal = 2
size_flags_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Wait" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer9"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Wait"
[node name="ColorTo" type="VBoxContainer" parent="Controls"]
offset_left = 666.0
offset_right = 987.0
offset_bottom = 570.0
rect_min_size = Vector2(320, 570)
rect_clip_content = true
size_flags_vertical = 0
[node name="VBoxContainer7" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="Controls/ColorTo"]
offset_right = 68.0
offset_bottom = 23.0
size_flags_horizontal = 2
size_flags_vertical = 0
text = "Color To:"
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer7"]
layout_mode = 2
text = "Step 9"
horizontal_alignment = 1
[node name="ColorPicker" type="ColorPicker" parent="Controls/ColorTo"]
offset_top = 27.0
offset_right = 321.0
offset_bottom = 539.0
size_flags_horizontal = 2
size_flags_vertical = 2
__meta__ = {
"_edit_use_anchors_": false
}
[node name="Countdown" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer7"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Countdown"
[connection signal="tween_step" from="Tween" to="." method="_on_Tween_tween_step"]
[connection signal="value_changed" from="Top/Timeline" to="." method="_on_Timeline_value_changed"]
[connection signal="color_changed" from="Controls/ColorFrom/ColorPicker" to="." method="_on_ColorPicker_color_changed"]
[connection signal="color_changed" from="Controls/ColorTo/ColorPicker" to="." method="_on_ColorPicker_color_changed"]
[node name="VBoxContainer8" type="VBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer"]
layout_mode = 2
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer8"]
layout_mode = 2
text = "Step 10"
horizontal_alignment = 1
[node name="Enlarge" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer8"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Enlarge"
[node name="Vanish" type="CheckBox" parent="VBoxContainer/PanelContainer/VBoxContainer/HFlowContainer/VBoxContainer8"]
unique_name_in_owner = true
layout_mode = 2
button_pressed = true
text = "Vanish"
[node name="HSeparator" type="HSeparator" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
[node name="HBoxContainer4" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="Button2" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer4"]
layout_mode = 2
text = "Pause/Resume"
[node name="Button3" type="Button" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer4"]
layout_mode = 2
text = "Kill Tween"
[node name="HBoxContainer2" type="HBoxContainer" parent="VBoxContainer/PanelContainer/VBoxContainer"]
layout_mode = 2
alignment = 1
[node name="Label" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
layout_mode = 2
text = "Speed Scale"
[node name="SpeedSlider" type="HSlider" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(600, 0)
layout_mode = 2
size_flags_vertical = 4
max_value = 5.0
step = 0.01
value = 1.0
[node name="SpeedLabel" type="Label" parent="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer2"]
unique_name_in_owner = true
custom_minimum_size = Vector2(50, 0)
layout_mode = 2
text = "1x"
horizontal_alignment = 1
[node name="Progress" type="TextureProgressBar" parent="VBoxContainer/PanelContainer/VBoxContainer"]
unique_name_in_owner = true
layout_mode = 2
size_flags_horizontal = 4
step = 0.001
texture_under = SubResource("GradientTexture2D_md057")
texture_progress = SubResource("GradientTexture2D_35fte")
[node name="Node2D" type="Node2D" parent="."]
[node name="Icon" type="Sprite2D" parent="Node2D"]
unique_name_in_owner = true
position = Vector2(99, 165)
texture = ExtResource("2_tapbf")
[node name="CountdownLabel" type="Label" parent="Node2D/Icon"]
unique_name_in_owner = true
visible = false
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -32.0
offset_top = -32.0
offset_right = -32.0
offset_bottom = -32.0
grow_horizontal = 2
grow_vertical = 2
theme_override_colors/font_color = Color(1, 1, 1, 1)
theme_override_colors/font_outline_color = Color(0, 0, 0, 1)
theme_override_constants/outline_size = 16
theme_override_font_sizes/font_size = 32
text = "10
"
horizontal_alignment = 1
vertical_alignment = 1
[node name="Path2D" type="Path2D" parent="."]
position = Vector2(473, 204)
curve = SubResource("Curve2D_7nae7")
[connection signal="toggled" from="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3/Infinite" to="." method="inifnite_toggled"]
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer3/Button" to="." method="start_animation"]
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer4/Button2" to="." method="pause_resume"]
[connection signal="pressed" from="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer4/Button3" to="." method="kill_tween"]
[connection signal="value_changed" from="VBoxContainer/PanelContainer/VBoxContainer/HBoxContainer2/SpeedSlider" to="." method="speed_changed"]

Binary file not shown.

View File

@@ -6,40 +6,22 @@
; [section] ; section goes between []
; param=value ; assign values to parameters
config_version=4
config_version=5
[application]
config/name="Tween Demo"
config/description="A demo showing advanced tween usage."
run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.0")
run/low_processor_mode=true
config/icon="res://icon.png"
target_fps=60
[debug]
gdscript/warnings/return_value_discarded=false
[display]
window/size/height=800
window/dpi/allow_hidpi=true
window/stretch/mode="2d"
window/stretch/mode="canvas_items"
window/stretch/aspect="expand"
window/size/height=800
stretch/aspect="keep_width"
stretch/mode="2d"
[gdnative]
singletons=[]
[memory]
multithread/thread_rid_pool_prealloc=60
[rendering]
quality/driver/driver_name="GLES2"
vram_compression/import_etc=true
vram_compression/import_etc2=false
environment/default_clear_color=Color(0.2349, 0.2349, 0.27, 1)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 64 KiB

After

Width:  |  Height:  |  Size: 43 KiB