-
Notifications
You must be signed in to change notification settings - Fork 46
docs: add animation reference #74
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
MakinoharaShoko
merged 1 commit into
OpenWebGAL:main
from
HardyNLee:doc/animation-reference
Nov 3, 2025
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| # 动画参考 | ||
|
|
||
| WebGAL 支持设置连续的 [变换效果](../others/transform-reference.md) ,从而实现多段动画。 | ||
|
|
||
| 一个变换效果对象如 | ||
| ``` json | ||
| { | ||
| "position": { | ||
| "x":-500, | ||
| "y":20 | ||
| }, | ||
| "rotation":0.3, | ||
| "blur":10 | ||
| } | ||
| ``` | ||
|
|
||
| 一个动画片段对象则是在变换效果对象的基础上,添加了一些其他属性,如持续时间等 | ||
| ``` json | ||
| { | ||
| "position": { | ||
| "x":-500, | ||
| "y":20 | ||
| }, | ||
| "rotation":0.3, | ||
| "blur":10, | ||
| "duration":500, | ||
| "ease":"easeInOut" | ||
| } | ||
| ``` | ||
|
|
||
| 多个动画片段对象可以组成一个动画 | ||
| ``` json | ||
| [ | ||
| { | ||
| "duration":0 | ||
| }, | ||
| { | ||
| "position": { | ||
| "x":-500, | ||
| "y":20 | ||
| }, | ||
| "duration":500 | ||
| }, | ||
| { | ||
| "rotation":0.3, | ||
| "duration":300 | ||
| }, | ||
| { | ||
| "blur":10, | ||
| "duration":200 | ||
| } | ||
| ] | ||
| ``` | ||
|
|
||
| 除了一些必要的属性外(如 duration),动画片段对象的很多属性都可以省略,WebGAL 会根据情况使用默认值或者继承现有值来补全。 | ||
|
|
||
| :::info | ||
| 继承现有值的「现有值」是指,在执行动画前,目标对象的变换效果快照,而不是上一个动画片段的结束状态。 | ||
| ::: | ||
|
|
||
| ```webgal | ||
| ; 立绘对象初始坐标为 (-500,0) | ||
| changeFigure:character_a/normal.png -id=aaa -transform={"position":{"x":-500,"y":0}}; | ||
| ; 多段动画的坐标依次为 | ||
| ; (-500,0) -> (500,0) -> (-500,20) | ||
| setTempAnimation:[{"duration":0},{"position":{"x":500},"duration":500},{"position":{"y":20},"duration":500}] -target=aaa; | ||
| ``` | ||
|
|
||
| 动画里的第一个片段为起始状态,通常 duration 设为 0 即可,即使设置了大于 0 的数,也不会有动画效果。 | ||
| 您仍然可以为第一个片段设置变换效果属性,这样可以在动画开始时直接跳转到指定状态。 | ||
|
|
||
| ```webgal | ||
| ; 立绘对象初始坐标为 (-500,0) | ||
| changeFigure:character_a/normal.png -id=aaa; | ||
| ; 从左走到右,动画开始时直接跳转到左边 | ||
| setTempAnimation:[{"position":{"x":-500},"duration":0},{"position":{"x":500},"duration":1000}] -target=aaa; | ||
| ``` | ||
|
|
||
| ## 参数 | ||
|
|
||
| ### duration | ||
| - 数字 | ||
| - 单位:毫秒 | ||
| - 必填 | ||
|
|
||
| 每个动画片段的持续时间。 | ||
|
|
||
| ```webgal | ||
| changeFigure:1/open_eyes.png -id=aaa; | ||
| setTempAnimation:[{"position":{"x":-500},"duration":0},{"position":{"x":500},"duration":1000}] -target=aaa; | ||
| ``` | ||
|
|
||
| ### ease | ||
| - 字符串 | ||
|
|
||
| 填写缓动类型,控制动画的缓动效果,默认值为 `easeInOut`,可选值包括 | ||
| - `linear`:线性 | ||
| - `easeIn`:缓入 | ||
| - `easeOut`:缓出 | ||
| - `easeInOut`:缓入缓出 | ||
| - `circIn`:圆形缓入 | ||
| - `circOut`:圆形缓出 | ||
| - `circInOut`:圆形缓入缓出 | ||
| - `backIn`:起点回弹 | ||
| - `backOut`:终点回弹 | ||
| - `backInOut`:起止回弹 | ||
| - `bounceIn`:起点弹跳 | ||
| - `bounceOut`:终点弹跳 | ||
| - `bounceInOut`:起止弹跳 | ||
| - `anticipate`:预先反向 | ||
|
|
||
| 任何其他字符串都会回退到默认值。 | ||
|
|
||
| ```webgal | ||
| changeFigure:1/open_eyes.png -id=aaa; | ||
| setTempAnimation:[{"position":{"x":-500},"duration":0},{"position":{"x":500},"duration":1000,"ease":"bounceOut"}] -target=aaa; | ||
| ``` | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这行注释
立绘对象初始坐标为 (-500,0)具有误导性。在changeFigure命令中并未指定transform,因此立绘的初始坐标应为默认的(0,0)。动画的第一个片段{"position":{"x":-500},"duration":0}实际上是将立绘瞬移到(-500,0)位置,然后才开始后续动画。为了确保文档的准确性,建议修改此注释以反映真实的初始状态。