unity dotween多个动作叠加执行

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

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

dotween也有该功能的实现,DOBlendableMoveBy

DOBlendableMoveBy(Vector3 by, float duration, bool snapping)

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);

其他还有:

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)

还有个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();

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值