吐温¶
类别: 核心
简要说明¶
随时间平滑地设置节点属性的动画。
方法¶
follow_method ( Object object, String method, Variant initial_val, Object target, String target_method, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
follow_property ( Object object, NodePath property, Variant initial_val, Object target, NodePath target_property, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
get_runtime ( ) const |
|
interpolate_callback ( Object object, float duration, String callback, Variant arg1=null, Variant arg2=null, Variant arg3=null, Variant arg4=null, Variant arg5=null ) |
|
interpolate_deferred_callback ( Object object, float duration, String callback, Variant arg1=null, Variant arg2=null, Variant arg3=null, Variant arg4=null, Variant arg5=null ) |
|
interpolate_method ( Object object, String method, Variant initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
interpolate_property ( Object object, NodePath property, Variant initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
is_active ( ) const |
|
remove_all ( ) |
|
reset_all ( ) |
|
resume_all ( ) |
|
无效 |
set_active ( bool active ) |
start ( ) |
|
stop_all ( ) |
|
targeting_method ( Object object, String method, Object initial, String initial_method, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
targeting_property ( Object object, NodePath property, Object initial, NodePath initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 ) |
|
tell ( ) const |
枚举¶
枚举 TweenProcessMode :
TWEEN_PROCESS_PHYSICS = 0 ——Tween更新了
_physics_process
回调。TWEEN_PROCESS_IDLE = 1 ——Tween更新了
_process
回调。
枚举 TransitionType :
TRANS_LINEAR = 0 ---动画是线性插值的。
TRANS_SINE = 1 ---动画使用正弦函数进行插值。
TRANS_QUINT = 2 ---动画用五次函数(5的幂)插值。
TRANS_QUART = 3 ---动画用四次函数(4的幂)插值。
TRANS_QUAD = 4 ---动画用二次函数(2的幂)插值。
TRANS_EXPO = 5 ---动画用指数函数(x的幂)插值。
TRANS_ELASTIC = 6 ---动画是用弹性插值的,在边上晃动。
TRANS_CUBIC = 7 ---动画是用一个立方函数(3的幂)插值的。
TRANS_CIRC = 8 ---动画使用平方根的函数进行插值。
TRANS_BOUNCE = 9 ---动画是通过在末端反弹来插值的。
TRANS_BACK = 10 ---动画在结尾处插入后退。
枚举 EaseType :
EASE_IN = 0 ——插补开始缓慢,最后加速。
EASE_OUT = 1 ——插补开始快,结束时慢。
EASE_IN_OUT = 2 ——放松和放松的结合。插值在两端最慢。
EASE_OUT_IN = 3 ——放松和放松的结合。插值在两端都是最快的。
描述¶
Tweens对于需要在一个值范围内插值数值属性的动画很有用。名字 吐温 来自 in-betweening ,您指定的动画技术 关键帧 计算机对它们之间出现的帧进行插值。
下面是一个使二维节点在两个位置之间平稳移动的简单用法示例:
var tween = get_node("Tween")
tween.interpolate_property($Node2D, "position",
Vector2(0, 0), Vector2(100, 100), 1,
Tween.TRANS_LINEAR, Tween.EASE_IN_OUT)
tween.start()
许多方法都需要属性名,例如 "position"
上面。通过将鼠标悬停在检查器中的属性上,可以找到正确的属性名。您还可以使用 "property:component"
(例如) position:x
,仅适用于该特定组件。
许多方法都可以接受 trans_type
和 ease_type
. 第一个接受 TransitionType 常量,并引用处理动画计时的方式(请参见 http://easings.net/
例如)。第二个接受 EaseType 常量,并控制 trans_type
应用于插值(在开始、结束或两者中)。如果你不知道该选择哪种过渡和放松,你可以尝试不同的方法。 TransitionType 常量 EASE_IN_OUT 用最漂亮的。
属性描述¶
TweenProcessMode playback_process_mode
违约 |
1 |
设定器 |
设置进程模式(值) |
吸气剂 |
获取进程模式()。 |
Tween的动画处理线程。见 TweenProcessMode .
float playback_speed
违约 |
1.0 |
设定器 |
设置速度刻度(值) |
吸气剂 |
获取速度刻度 |
吐温的速度倍增器。例如,将其设置为 1.0
对于正常速度, 2.0
两倍正常速度,或 0.5
正常速度的一半。值 0
暂停动画,但另请参见 set_active 或 stop_all 为此。
bool repeat
违约 |
假 |
设定器 |
设置重复(值) |
吸气剂 |
是重复()) |
如果 true
,吐温圈。
方法说明¶
bool follow_method ( Object object, String method, Variant initial_val, Object target, String target_method, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
跟随 method
属于 object
并将返回值应用于 target_method
属于 target
,从开始 initial_val
对于 duration
秒, delay
稍后。方法是用连续值调用的。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
bool follow_property ( Object object, NodePath property, Variant initial_val, Object target, NodePath target_property, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
跟随 property
属于 object
并应用于 target_property
属于 target
,从开始 initial_val
对于 duration
秒, delay
几秒钟后。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
float get_runtime ( ) const
返回所有花间结束所需的总时间。如果你有两个花呢,一个持续10秒,另一个持续20秒,它会返回20秒,因为到那时所有花呢都会完成。
bool interpolate_callback ( Object object, float duration, String callback, Variant arg1=null, Variant arg2=null, Variant arg3=null, Variant arg4=null, Variant arg5=null )
调用 callback
属于 object
之后 duration
. arg1
-`` arg5``是要传递给回调的参数。
bool interpolate_deferred_callback ( Object object, float duration, String callback, Variant arg1=null, Variant arg2=null, Variant arg3=null, Variant arg4=null, Variant arg5=null )
调用 callback
属于 object
之后 duration
在主螺纹上(类似于 Object.call_deferred ) arg1
-`` arg5``是要传递给回调的参数。
bool interpolate_method ( Object object, String method, Variant initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
动画 method
属于 object
从 initial_val
到 final_val
对于 duration
秒, delay
几秒钟后。方法是用连续值调用的。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
bool interpolate_property ( Object object, NodePath property, Variant initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
动画 property
属于 object
从 initial_val
到 final_val
对于 duration
秒, delay
几秒钟后。将初始值设置为 null
使用属性的当前值。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
bool is_active ( ) const
返回 true
如果有孩子正在跑步。
注: 这种方法不考虑已经结束的吐温。
根据对象和属性/方法对,停止动画并移除中间层。默认情况下,除非 key
指定。
bool remove_all ( )
停止动画并删除所有中间层。
根据对象和属性/方法对,将tween重置为其初始值(给定的值,而不是tween之前的值)。默认情况下,除非 key
指定。
bool reset_all ( )
将所有tween重置为其初始值(给定的值,而不是tween之前的值)。
根据对象和属性/方法对,继续对停止的Tween设置动画。默认情况下,所有花间均恢复,除非 key
指定。
bool resume_all ( )
继续为所有停止的Tween设置动画。
将插值设置为给定的 time
几秒钟后。
void set_active ( bool active )
激活/停用吐温。另请参见 stop_all 和 resume_all .
bool start ( )
开始吐温。您可以在此之前和之后定义动画。
根据对象和属性/方法对停止tween。默认情况下,所有花呢都停止,除非 key
指定。
bool stop_all ( )
停止设置所有花间动画。
bool targeting_method ( Object object, String method, Object initial, String initial_method, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
动画 method
属于 object
从返回的值 initial_method
到 final_val
对于 duration
秒, delay
几秒钟后。方法是通过使用连续值调用它们来设置动画的。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
bool targeting_property ( Object object, NodePath property, Object initial, NodePath initial_val, Variant final_val, float duration, TransitionType trans_type, EaseType ease_type, float delay=0 )
动画 property
属于 object
从当前值 initial_val
性质 initial
到 final_val
对于 duration
秒, delay
几秒钟后。
使用 TransitionType 对于 trans_type
和 EaseType 对于 ease_type
参数。这些值控制插值的时间和方向。有关详细信息,请参见类描述。
float tell ( ) const
返回tween的当前时间。