Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Animation

Inherits: Resource < RefCounted < Object

存放的是用于对引擎中的任何对象进行动画处理的数据。

Description

这个资源存放的是用于对引擎中的任何对象进行动画处理的数据。动画分为轨道,轨道必须与节点关联。向轨道添加定时关键帧(事件)后,节点的状态可以随时间变化。

# 创建动画,让“Enemy”节点在 0.5 秒内
# 向右移动 100 像素。
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)

动画只是数据的容器,必须添加至 AnimationPlayer 等节点才能进行播放。动画轨道分为不同的类型,不同的类型有各自不同的专属方法。可用的类型请查看 TrackType

注意:对于 3D 的位置、旋转、缩放,推荐使用专门的 TYPE_POSITION_3DTYPE_ROTATION_3DTYPE_SCALE_3D 轨道类型,不要使用 TYPE_VALUE,性能更高。

Tutorials

Properties

float

length

1.0

LoopMode

loop_mode

0

float

step

0.1

Methods

int

add_track ( TrackType type, int at_position=-1 )

StringName

animation_track_get_key_animation ( int track_idx, int key_idx ) const

int

animation_track_insert_key ( int track_idx, float time, StringName animation )

void

animation_track_set_key_animation ( int track_idx, int key_idx, StringName animation )

float

audio_track_get_key_end_offset ( int track_idx, int key_idx ) const

float

audio_track_get_key_start_offset ( int track_idx, int key_idx ) const

Resource

audio_track_get_key_stream ( int track_idx, int key_idx ) const

int

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

bool

audio_track_is_use_blend ( int track_idx ) const

void

audio_track_set_key_end_offset ( int track_idx, int key_idx, float offset )

void

audio_track_set_key_start_offset ( int track_idx, int key_idx, float offset )

void

audio_track_set_key_stream ( int track_idx, int key_idx, Resource stream )

void

audio_track_set_use_blend ( int track_idx, bool enable )

Vector2

bezier_track_get_key_in_handle ( int track_idx, int key_idx ) const

Vector2

bezier_track_get_key_out_handle ( int track_idx, int key_idx ) const

float

bezier_track_get_key_value ( int track_idx, int key_idx ) const

int

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

float

bezier_track_interpolate ( int track_idx, float time ) const

void

bezier_track_set_key_in_handle ( int track_idx, int key_idx, Vector2 in_handle,