动画

Inherits: Resource < Reference < Object

类别: 核心

简要说明

包含用于为引擎中的所有内容设置动画的数据。

属性

float

length

1.0

bool

loop

float

step

0.1

方法

int

add_track ( TrackType type, int at_position=-1 )

String

animation_track_get_key_animation ( int idx, int key_idx ) const

int

animation_track_insert_key ( int track, float time, String animation )

无效

animation_track_set_key_animation ( int idx, int key_idx, String animation )

float

audio_track_get_key_end_offset ( int idx, int key_idx ) const

float

audio_track_get_key_start_offset ( int idx, int key_idx ) const

Resource

audio_track_get_key_stream ( int idx, int key_idx ) const

int

audio_track_insert_key ( int track, float time, Resource stream, float start_offset=0, float end_offset=0 )

无效

audio_track_set_key_end_offset ( int idx, int key_idx, float offset )

无效

audio_track_set_key_start_offset ( int idx, int key_idx, float offset )

无效

audio_track_set_key_stream ( int idx, int key_idx, Resource stream )

Vector2

bezier_track_get_key_in_handle ( int idx, int key_idx ) const

Vector2

bezier_track_get_key_out_handle ( int idx, int key_idx ) const

float

bezier_track_get_key_value ( int idx, int key_idx ) const

int

bezier_track_insert_key ( int track, float time, float value, Vector2 in_handle=Vector2( 0, 0 ), Vector2 out_handle=Vector2( 0, 0 ) )

float

bezier_track_interpolate ( int track, float time ) const

无效

bezier_track_set_key_in_handle ( int idx, int key_idx, Vector2 in_handle )

无效

bezier_track_set_key_out_handle ( int idx, int key_idx, Vector2 out_handle )

无效

bezier_track_set_key_value ( int idx, int key_idx, float value )

无效

clear ( )

无效

copy_track ( int track, Animation to_animation )

int

find_track ( NodePath path ) const

int

get_track_count ( ) const

PoolIntArray

method_track_get_key_indices ( int idx, float time_sec, float delta ) const

String

method_track_get_name ( int idx, int key_idx ) const

Array

method_track_get_params ( int idx, int key_idx ) const

无效

remove_track ( int idx )

int

track_find_key ( int idx, float time, bool exact=false ) const

bool

track_get_interpolation_loop_wrap ( int idx ) const

InterpolationType

track_get_interpolation_type ( int idx ) const

int

track_get_key_count ( int idx ) const

float

track_get_key_time ( int idx, int key_idx ) const

float

track_get_key_transition ( int idx, int key_idx ) const

Variant

track_get_key_value ( int idx, int key_idx ) const

NodePath

track_get_path ( int idx ) const

TrackType

track_get_type ( int idx ) const

无效

track_insert_key ( int idx, float time, Variant key, float transition=1 )

bool

track_is_enabled ( int idx ) const

bool

track_is_imported ( int idx ) const

无效

track_move_down ( int idx )

无效

track_move_to ( int idx, int to_idx )

无效

track_move_up ( int idx )

无效

track_remove_key ( int idx, int key_idx )

无效

track_remove_key_at_position ( int idx, float position )

无效

track_set_enabled ( int idx, bool enabled )

无效

track_set_imported ( int idx, bool imported )

无效

track_set_interpolation_loop_wrap ( int idx, bool interpolation )

无效

track_set_interpolation_type ( int idx, InterpolationType interpolation )

无效

track_set_key_time ( int idx, int key_idx, float time )

无效

track_set_key_transition ( int idx, int key_idx, float transition )

无效

track_set_key_value ( int idx, int key, Variant value )

无效

track_set_path ( int idx, NodePath path )

无效

track_swap ( int idx, int with_idx )

int

transform_track_insert_key ( int idx, float time, Vector3 location, Quat rotation, Vector3 scale )

Array

transform_track_interpolate ( int idx, float time_sec ) const

PoolIntArray

value_track_get_key_indices ( int idx, float time_sec, float delta ) const

UpdateMode

value_track_get_update_mode ( int idx ) const

无效

value_track_set_update_mode ( int idx, UpdateMode mode )

信号

  • tracks_changed ( )

枚举

枚举 TrackType

  • TYPE_VALUE = 0 ---值跟踪节点属性中的设置值,但仅限于可以插入的值。

  • TYPE_TRANSFORM = 1 ---变换轨迹用于更改节点局部变换或骨骼姿势骨骼。过渡是内插的。

  • TYPE_METHOD = 2 ---方法跟踪每个键具有给定参数的调用函数。

  • TYPE_BEZIER = 3

  • TYPE_AUDIO = 4

  • TYPE_ANIMATION = 5

枚举 InterpolationType

  • INTERPOLATION_NEAREST = 0 ---无插值(最近值)。

  • INTERPOLATION_LINEAR = 1 ---线性插值。

  • INTERPOLATION_CUBIC = 2 ——三次插值。

枚举 UpdateMode

  • UPDATE_CONTINUOUS = 0 ---在关键帧之间更新。

  • UPDATE_DISCRETE = 1 ---在关键帧处更新并保留该值。

  • UPDATE_TRIGGER = 2 ---在关键帧处更新。

  • UPDATE_CAPTURE = 3

描述

动画资源包含用于为引擎中的所有内容设置动画的数据。动画分为多个轨迹,每个轨迹必须链接到一个节点。该节点的状态可以通过向轨迹添加定时键(事件)来随时间变化。

# This creates an animation that makes the node "Enemy" move to the right by
# 100 pixels in 1 second.
var animation = Animation.new()
var track_index = animation.add_track(Animation.TYPE_VALUE)
animation.track_set_path(track_index, "Enemy:position.x")
animation.track_insert_key(track_index, 0.0, 0)
animation.track_insert_key(track_index, 0.5, 100)

动画只是数据容器,必须添加到节点,如 AnimationPlayerAnimationTreePlayer 播放。

教程

属性描述

违约

1.0

设定器

设置长度(值)

吸气剂

获取长度()

动画的总长度(秒)。

注: 长度不由最后一个键分隔,因为这一个键可能在结束之前或之后,以确保正确的插值和循环。

违约

设定器

设置回路(值)

吸气剂

有u循环()

指示动画必须循环的标志。这用于正确插入动画周期,并提示播放机必须重新启动动画。

违约

0.1

设定器

设置步骤(值)

吸气剂

获取步骤()

动画步骤值。

方法说明

将轨迹添加到动画中。

  • String animation_track_get_key_animation ( int idx, int key_idx ) const

  • void animation_track_set_key_animation ( int idx, int key_idx, String animation )

  • float audio_track_get_key_end_offset ( int idx, int key_idx ) const

  • float audio_track_get_key_start_offset ( int idx, int key_idx ) const

  • void audio_track_set_key_end_offset ( int idx, int key_idx, float offset )

  • void audio_track_set_key_start_offset ( int idx, int key_idx, float offset )

  • void audio_track_set_key_stream ( int idx, int key_idx, Resource stream )

  • Vector2 bezier_track_get_key_in_handle ( int idx, int key_idx ) const

  • Vector2 bezier_track_get_key_out_handle ( int idx, int key_idx ) const

  • float bezier_track_get_key_value ( int idx, int key_idx ) const

  • void bezier_track_set_key_in_handle ( int idx, int key_idx, Vector2 in_handle )

  • void bezier_track_set_key_out_handle ( int idx, int key_idx, Vector2 out_handle )

  • void bezier_track_set_key_value ( int idx, int key_idx, float value )

  • void clear ( )

清除动画(清除所有轨迹并全部重置)。

添加一个新曲目,它是给定曲目的副本 to_animation .

返回指定曲目的索引。如果找不到音轨,返回-1。

  • int get_track_count ( ) const

返回动画中的轨迹数量。

返回给定位置和增量时间的方法跟踪的所有关键索引。

  • String method_track_get_name ( int idx, int key_idx ) const

返回方法跟踪的方法名。

  • Array method_track_get_params ( int idx, int key_idx ) const

返回在给定轨道中给定键的方法轨道上要调用的参数值。

  • void remove_track ( int idx )

通过指定跟踪索引删除跟踪。

在给定轨道中按时间查找键索引。或者,只在给出确切时间的情况下找到它。

  • bool track_get_interpolation_loop_wrap ( int idx ) const

返回 true 如果轨道在 idx 环绕插值循环。默认情况下,新轨迹环绕插值循环。

返回给定轨迹的插值类型。

  • int track_get_key_count ( int idx ) const

返回给定曲目中的键数。

  • float track_get_key_time ( int idx, int key_idx ) const

返回键所在的时间。

  • float track_get_key_transition ( int idx, int key_idx ) const

返回特定键的过渡曲线(放宽)(请参见内置数学函数 @GDScript.ease

返回给定轨道中给定键的值。

获取轨迹的路径。有关路径格式的详细信息,请参阅 track_set_path .

获取曲目的类型。

在给定的轨道中插入通用键。

  • bool track_is_enabled ( int idx ) const

返回 true 如果轨道在索引处 idx 启用。

  • bool track_is_imported ( int idx ) const

返回 true 如果导入了给定的曲目。否则,返回 false .

  • void track_move_down ( int idx )

向下移动轨迹。

  • void track_move_to ( int idx, int to_idx )

更改轨道的索引位置 idx 到中定义的 to_idx .

  • void track_move_up ( int idx )

向上移动轨迹。

  • void track_remove_key ( int idx, int key_idx )

在给定的跟踪中按索引删除键。

  • void track_remove_key_at_position ( int idx, float position )

在给定曲目中按位置(秒)删除键。

  • void track_set_enabled ( int idx, bool enabled )

启用/禁用给定的曲目。默认情况下启用曲目。

  • void track_set_imported ( int idx, bool imported )

将给定轨道设置为导入或不导入。

  • void track_set_interpolation_loop_wrap ( int idx, bool interpolation )

如果 true ,轨道 idx 环绕插值循环。

设置给定轨迹的插值类型。

  • void track_set_key_time ( int idx, int key_idx, float time )

设置现有密钥的时间。

  • void track_set_key_transition ( int idx, int key_idx, float transition )

为特定键设置过渡曲线(放宽)(请参见内置数学函数 @GDScript.ease

设置现有键的值。

设置轨迹的路径。路径必须是指向节点的有效场景树路径,并且必须从将复制动画的节点的父节点开始指定路径。控制属性或骨骼的轨迹必须在路径后附加其名称,由分隔 ":" .

例如, "character/skeleton:ankle""character/mesh:transform/local" .

  • void track_swap ( int idx, int with_idx )

调换赛道 idx 的索引位置 with_idx .

插入变换轨迹的变换键。

  • Array transform_track_interpolate ( int idx, float time_sec ) const

返回给定时间(以秒为单位)变换轨迹的插值值。由3个元素组成的数组:位置 (Vector3 )旋转 (Quat )和规模 (Vector3

返回给定位置和增量时间的值跟踪的所有关键索引。

返回值跟踪的更新模式。

设置更新模式 (UPDATE_* )价值轨迹。