Godot Engine 3.2 Alpha2
AnimationPlayer
可以说是Godot的一大亮点,该类继承自Node
这意味着Godot动画在2D/3D以及UI上都可以使用并且拥有同样的工作逻辑,AnimationPlayer
可以置于节点树的不同层级,用于管理一个或多个物体上的动画,这个特性使它衍生出很多高级的玩法。AnimationPlayer
还自带一个非常直观好用的可视化编辑器。
常用属性
类型 | 属性名 | 说明 |
---|---|---|
String | assigned_animation | |
String | autoplay | 注意:是String 而不是bool ,当场景加载时默认播放的动画片段,默认为"" |
String | current_animation | 当前播放的动画名,如果没有的话,默认为"" |
float | current_animation_length | |
float | current_animation_position | |
bool | playback_active | |
float | playback_default_blend_time | |
AnimationProcessMode | playback_process_mode | 枚举值ANIMATION_PROCESS_PHYSICS = 0 常用于物理性物体;ANIMATION_PROCESS_IDLE = 1 空闲过程;ANIMATION_PROCESS_MANUAL = 2 手动 |
float | playback_speed | |
NodePath | root_node | 遍历引用的起始位置,默认是".." 即其父节点 |
常用方法
类型 | 属性名 | 说明 |
---|---|---|
Error | add_animation ( String name, Animation animation ) | |
void | advance ( float delta ) | |
String | animation_get_next ( String anim_from ) const | |
void | animation_set_next ( String anim_from, String anim_to ) | |
void | clear_caches ( ) | |
void | clear_queue ( ) | |
String | find_animation ( Animation animation ) const | |
Animation | get_animation ( String name ) const | |
PoolStringArray | get_animation_list ( ) const | |
float | get_blend_time ( String anim_from, String anim_to ) const | |
float | get_playing_speed ( ) const | |
PoolStringArray | get_queue ( ) | |
bool | has_animation ( String name ) const | 查看是否有名为name 的动画片段 |
bool | is_playing ( ) const | 返回当前是否有动画播放 |
void | play ( String name=”“, float custom_blend=-1, float custom_speed=1.0, bool from_end=false ) | 播放动画,如果 custom_speed= -1.0, from_end= true,意味着回放 |
void | play_backwards ( String name=”“, float custom_blend=-1 ) | |
void | queue ( String name ) | |
void | remove_animation ( String name ) | |
void | rename_animation ( String name, String newname ) | |
void | seek ( float seconds, bool update=false ) | |
void | set_blend_time ( String anim_from, String anim_to, float sec ) | |
void | stop ( bool reset=true ) | 停止当前动画 |