-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDemo_TargetType.gd
More file actions
82 lines (73 loc) · 1.87 KB
/
Demo_TargetType.gd
File metadata and controls
82 lines (73 loc) · 1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
extends Control
func _on_button_animate_property_pressed() -> void:
#
# To animate property, please do the following:
#
Motion \
.spring(%Icon, "position") \
.to([
randf() * (%Panel.size.x - %Icon.size.x),
randf() * (%Panel.size.y - %Icon.size.y),
])
#
# It supports following types as target property:
#
# - float,
# - int,
# - Packed*Array,
# - Basis,
# - Transform2D,
# - Transform3D,
# - Color,
# - Vector2/3/4i and
# - Vector2/3/4.
#
# If no type annotation is provided, you must supply a type hint as follows:
#
# Motion.tween(%Icon, "position", TYPE_VECTOR2)
# ^^^^^^^^^^^^
func _on_button_animate_method_1_pressed() -> void:
#
# To animate method, please do the following:
#
var w := randf()
Motion \
.spring(%Icon, "set_scale") \
.from(%Icon.scale) \
.to([
lerpf(0.5, 3.0, w),
lerpf(0.5, 3.0, w),
])
#
# If no type annotation is provided, you must supply a type hint as follows:
#
# Motion.tween(self, "_set_scale", TYPE_VECTOR2)
# ^^^^^^^^^^^^
# ".from" can be omitted, but it is specified to inherit the current value.
#
func _on_button_animate_method_2_pressed() -> void:
#
# Callables can also be animated:
#
@warning_ignore("shadowed_variable_base_class")
Motion \
.spring(%Icon.set_rotation) \
#.spring(
# func (rotation: float) -> void:
# %Icon.rotation_degrees = rotation,
# TYPE_FLOAT) \
.from(%Icon.rotation) \
.to(randf_range(-PI, PI))
#
# ".from" can be omitted, but it is specified to
# inherit the current value.
#
# If no type annotation is provided,
# you must supply a type hint as follows:
#
# Motion.tween(_set_scale, TYPE_FLOAT)
# ^^^^^^^^^^
# When animating a lambda defined on the spot,
# duplicates are not eliminated.
# Because different instances cannot be determined to be identical.
#