緩動函數指定動畫效果在執行時的速度,使其看起來更加真實。html
現實物體照着必定節奏移動,並非一開始就移動很快的。當咱們打開抽屜時,首先會讓它加速,而後慢下來。當某個東西往下掉時,首先是越掉越快,撞到地上後回彈,最終才又碰觸地板。c#
名稱 | 描述 (速度與時間的關係) |
---|---|
倒退緩衝(BackEase) | 讓動畫在繼續以前日後退一點。這有點象在斜坡上啓動汽車,會日後倒退一點而後才前進。 |
彈跳緩衝(BounceEase) | 在咱們前面的例子中,生成的就是個彈跳反衝。 |
圓緩衝(CircleEase) | 基於三角函數(圓函數)來加速動畫,一開始的加速度比較慢,越日後加速度越快。 |
立方體緩衝(CubicEase) | 與圓緩衝相似,可是是基於立方體函數的時間來產生一個一開始加速度較慢而後愈來愈快的動畫。 |
伸縮緩衝(ElasticEase) | 相似於彈跳緩衝(BounceEase),它會讓一個值擺動直到停下爲止。 |
指數緩衝(ExponentialEase) | 相似於圓緩衝和立方體緩衝,只是加速度的值是按照指數來變化的。 |
乘方緩衝(PowerEase) | 這是一種指數緩衝,緩衝的值與時間的乘方成比例。 |
平方緩衝(QuadraticEase) | 很是相似於CubicEase,除了在這個緩衝中,值是基於時間的平方。 |
四次方緩衝(QuarticEase) | 相似於Cubic和Quadratic,只是值是基於時間的立方。 |
五次方緩衝(QuinticEase) | 相似於Cubic、Quadratic和Quartic,值基於時間的五次方。 |
正弦緩衝(SineEase) | 沿着正弦波來對值進行加速。 |
SetEase(Ease easeType \ AnimationCurve animCurve \ EaseFunction customEase)
設置動畫的緩動。app
若是應用於一個序列而不是Tweener,這個ease將被應用到整個序列,就好像它是一個單一的動畫時間軸。序列老是有緩動。默認狀況下是線性的,獨立於全局默認設置.函數
You can pass it either a default ease (Ease – to see how default ease curves look, check out easings.net), an AnimationCurve or a custom ease function (see example).動畫
此外,還能夠設置如下可選參數:它們只在Back和Elastic的eases中工做。ui
overshoot
Eventual overshoot to use with Back ease (default is 1.70158), or number of flashes to use with Flash ease.amplitude
Eventual amplitude to use with Elastic ease (default is 1.70158).period
Eventual period to use with Elastic ease (default is 0), or power to use with Flash ease.Flash
, InFlash
, OutFlash
,InOutFlash
:這些緩動會對動畫應用一個閃爍效果,下面的圖片很清楚地代表了這點this
overshoot
: Indicates the total number of flashes to apply. An even number will end the tween on the starting value, while an odd one will end it on the end value.period
: Indicates the power in time of the ease, and must be between -1 and 1. 0 is balanced, 1 fully weakens the ease in time, -1 starts the ease fully weakened and gives it power towards the end.EaseFactory.StopMotion
是一個額外的Layer,你能夠添加到你的easings,使他們的行爲就好像他們是在中止運動spa
EaseFactory.StopMotion(int fps, Ease\AnimationCurve\EaseFunction ease)
transform.DOMoveX(4, 1).SetEase(EaseFactory.StopMotion(5, Ease.InOutQuint));
public enum Ease { Unset = 0, Linear = 1, InSine = 2, OutSine = 3, InOutSine = 4, InQuad = 5, OutQuad = 6, InOutQuad = 7, InCubic = 8, OutCubic = 9, InOutCubic = 10, InQuart = 11, OutQuart = 12, InOutQuart = 13, InQuint = 14, OutQuint = 15, InOutQuint = 16, InExpo = 17, OutExpo = 18, InOutExpo = 19, InCirc = 20, OutCirc = 21, InOutCirc = 22, InElastic = 23, OutElastic = 24, InOutElastic = 25, InBack = 26, OutBack = 27, InOutBack = 28, InBounce = 29, OutBounce = 30, InOutBounce = 31, Flash = 32, InFlash = 33, OutFlash = 34, InOutFlash = 35, // // 摘要: // Don't assign this! It's assigned automatically when creating 0 duration tweens INTERNAL_Zero = 36, // // 摘要: // Don't assign this! It's assigned automatically when setting the ease to an AnimationCurve // or to a custom ease function INTERNAL_Custom = 37 }