godot-start/doc/demo10_animation/animation.md

83 lines
3.4 KiB
Markdown
Raw Normal View History

2022-07-08 10:28:13 +00:00
# 1. 动画系统
- godot中的动画其实就是一个一个图片的轮播
2021-10-08 10:58:02 +00:00
```
2022-07-08 10:28:13 +00:00
sprite解释上世纪70年代在德州电器公司一个叫Daniel Hillis的前辈最早把Sprite这个词用在计算机图形上在展示界面上
2021-10-08 10:58:02 +00:00
有一些东西在实现层面并不是和整个画面融为一体的而是『漂浮』在其他画面之上像『幽灵』一样所以被称为Sprite。
一张一张的图片组成了一个会动的精灵
```
2021-10-07 10:38:10 +00:00
![Image text](image/animation1.png)
![Image text](image/animation2.png)
![Image text](image/animation3.png)
![Image text](image/animation4.png)
![Image text](image/animation5.png)
2022-07-08 10:28:13 +00:00
- godot内置了通用的动画系统用以实现基于关键帧的动画。
```
除了支持标准的位移、旋转、缩放动画和帧动画之外,还支持任意组件属性和用户自定义属性的驱动,
再加上可任意编辑的时间曲线和创新的移动轨迹编辑功能,能够让内容生产人员不写一行代码就制作出细腻的各种动态效果。
```
2022-07-09 08:34:23 +00:00
# 2. Timer节点实现动画
2022-07-08 10:28:13 +00:00
- Timer节点意思是计时器秒表在godot中可以利用他的定时器特性来实现动画帧
2022-07-09 04:15:51 +00:00
- 看名字就知道这是一个“计时器”。在 Godot 中一切皆节点,所以看到这种*纯功能性*的节点不要觉得奇怪
- 我们完全可以不使用节点,直接使用代码 Timer.new() 动态创建一个计时器也是没任何问题的;
2022-07-08 10:28:13 +00:00
```
2022-07-09 04:15:51 +00:00
Timer 时间计时器节点的属性非常简单,根据需求可以设置其等待时间、重复计时以及是否自动开始,这些属性我们也可以在 GDScript 脚本中使用代码修改:
wait_time :等待时间,即计时时长,结束触发 timeout 信号
one_shot :是否是一次性,如果是,只会触发一次 timeout 信号
autostart :自动开始,载入场景后计时,也可以使用 start 方法手动开启
```
2022-07-09 08:34:23 +00:00
# 3. Tween节点实现动画
2022-07-09 04:15:51 +00:00
- 在游戏开发过程中,我们一般使用 AnimationPlayer 节点来实现移动、缩放、颜色渐变等动画效果
- Tween 即*渐进/过渡*的意思,从一种状态在一定时间内变化到另一种状态,从而产生一种视觉动画。
- 渐变节点使用非常简单方便,可以对一个物体的任意属性进行动画控制,当然,也可以同时处理多个动画对象。其主要方法有以下几个:
```
2023-11-18 04:26:10 +00:00
var tween: Tween = tween = create_tween()
# 无限循环动画
tween.set_loops()
2022-07-09 04:15:51 +00:00
Smoothly animates a node's properties over time.
Tweens are useful for animations requiring a numerical property to be interpolated over a range of values.
The name tween comes from in-betweening, an animation technique where you specify keyframes and the computer interpolates the frames that appear between them.
Tween is more suited than AnimationPlayer for animations where you don't know the final values in advance.
2022-07-08 10:28:13 +00:00
```
2021-10-07 10:38:10 +00:00
![Image text](image/animation6.png)
![Image text](image/animation7.png)
![Image text](image/animation8.png)
![Image text](image/animation9.png)
![Image text](image/animation10.png)
![Image text](image/animation11.png)
2022-07-09 04:15:51 +00:00
2022-07-09 08:34:23 +00:00
# 4. AnimationPlayer节点实现动画
2021-10-07 10:38:10 +00:00
2021-10-05 16:32:06 +00:00
- AnimationPlayer是时间和属性的变化是一种动画的表现
2022-07-09 04:15:51 +00:00
![Image text](image/animation12.png)
2022-07-09 08:34:23 +00:00
# 5. AnimatedSprite节点实现动画
2022-07-09 04:15:51 +00:00
2021-10-05 16:32:06 +00:00
- AnimatedSprite是序列帧的简便的用法
2021-10-07 15:47:42 +00:00
![Image text](image/animated1.png)
![Image text](image/animated2.png)
![Image text](image/animated3.png)