当前位置:   article > 正文

unity dotween多个动作叠加执行_dotween 并行

dotween 并行

coco2dx 的动画有XXTo和XXBy两类,分别是移动和递增2种方式,而且可以实现多个动作同时叠加进行(开启CC_ENABLE_STACKABLE_ACTIONS宏时,默认是开启的)。

By 算的是相对于节点对象的当前位置,To 算的是绝对位置,不考虑当前节点对象在哪。如果你想动作的表现是相对于 Node 当前位置的,就用 By,相对的想让动作的表现是按照坐标的绝对位置就用 To。

dotween也有该功能的实现,DOBlendableMoveBy

DOBlendableMoveBy(Vector3 by, float duration, bool snapping)
  • 1

Tweens a Transform’s position BY the given value (as if it was set to relative), in a way that allows other DOBlendableMove tweens to work together on the same target, instead than fight each other as multiple DOMove would do.
snapping If TRUE the tween will smoothly snap all values to integers.

// Tween a target by moving it by 3,3,0
// while blending another move by -3,0,0 that will loop 3 times
// (using the default OutQuad ease)
transform.DOBlendableMoveBy(new Vector3(3, 3, 0), 3);
transform.DOBlendableMoveBy(new Vector3(-3, 0, 0), 1f).SetLoops(3, LoopType.Yoyo);
  • 1
  • 2
  • 3
  • 4
  • 5

其他还有:

DOBlendableLocalMoveBy(Vector3 by, float duration, bool snapping)
DOBlendableRotateBy(Vector3 by, float duration, RotateMode mode)
DOBlendableLocalRotateBy(Vector3 by, float duration, RotateMode mode)
DOBlendableScaleBy(Vector3 by, float duration)
DOBlendableColor(Color to, float duration)
  • 1
  • 2
  • 3
  • 4
  • 5

还有个SetRelative接口,这个接口只是改了目标值的计算方式,并不能叠加:

If isRelative is TRUE sets the tween as relative (the endValue will be calculated as startValue + endValue instead of being used directly). In case of Sequences, sets all the nested tweens as relative.
IMPORTANT: Has no effect on From tweens, since in that case you directly choose if the tween is relative or not when chaining the From setting.
Has no effect if the tween has already started.
transform.DOMoveX(4, 1).SetRelative();

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/89802
推荐阅读
相关标签
  

闽ICP备14008679号