国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

CocosCreator:常用于動(dòng)畫的緩動(dòng)類Easing

2021-12-01 17:24 作者:會(huì)飛的蝸牛007  | 我要投稿

定義:以非線性的方式修改值的函數(shù),通常用于動(dòng)畫。

在cocoscreator中有easing各字段的屬性,預(yù)定義的?Easing?函數(shù)具有以下形式:

字段:

BounceIn:

跳轉(zhuǎn)到最終值,然后退回,最后確定最終值

BounceOut:

跳轉(zhuǎn)至最終值,退回 3 次,然后確定

CubicIn:

啟動(dòng)緩慢,然后逐漸加速

CubicInOut:

加速和減速。 通常是一個(gè)看起來(lái)正常的選擇

CubicOut:

快速啟動(dòng),然后減速

Linear:

線性轉(zhuǎn)換

SinIn:

平穩(wěn)加速

SinInOut:

加速進(jìn)入,減速退出

SinOut:

平穩(wěn)減速

SpringIn:

移動(dòng),然后跳轉(zhuǎn)至最終值

SpringOut:

????

迭代過(guò)度,然后返回

當(dāng)然還有很多,cocosCreator內(nèi)置了這些函數(shù),可以直接在tween中使用

creator3.2的API

cocoscreator3.x的api個(gè)人看起來(lái)很費(fèi)勁,所以還是到2.x中去扒

Easing:緩動(dòng)函數(shù)類,為?Tween?提供緩動(dòng)效果函數(shù)

關(guān)于這些緩動(dòng)函數(shù)的效果:cocoscreator2.x還提供了效果圖:

https://easings.net/cn

文檔說(shuō)明也很詳細(xì):https://docs.cocos.com/creator/2.3/api/zh/classes/Easing.html?h=easing

使用?easing?來(lái)使緩動(dòng)更生動(dòng),cc.tween?針對(duì)不同的情況提供了多種使用方式:

// 傳入easing名字,直接使用內(nèi)置easing函數(shù)

cc.tween().to(1, { scale: 2 }, {easing: 'sineOutIn'})

// 使用自定義easing函數(shù)

cc.tween().to(1, { scale: 2 }, {easing: t => t*t; })

// 只對(duì)單個(gè)屬性使用easing函數(shù)// value 必須與easing或者 progress 配合使用

cc.tween().to(1, { scale: 2, position: { value: cc.v3(100, 100, 100),easing: 'sineOutIn' } })

相對(duì)于?easing,自定義 progress 函數(shù)可以更自由的控制緩動(dòng)的過(guò)程:

// 對(duì)所有屬性自定義 progress

cc.tween().to(1, { scale: 2, rotation: 90 },?

{ ?

progress: (start, end, current, ratio) => { ? ?

????return start + (end - start) * ratio; ?

????}?

})


// 對(duì)單個(gè)屬性自定義 progress

cc.tween().to(1, { ?scale: 2, ?position: { ? ?

????value: cc.v3(), ? ?

????progress: (start, end, current, t) => { ? ? ?????????

????????return start.lerp(end, t, current); ? ?

????} ?

????}?

????}

)

// 注意,傳入的屬性為?cc.Vec3,所以需要使用 Vec3.lerp 進(jìn)行插值計(jì)算?


CocosCreator:常用于動(dòng)畫的緩動(dòng)類Easing的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
米林县| 益阳市| 盐亭县| 日土县| 三都| 合江县| 遵义市| 万山特区| 孝昌县| 文山县| 同德县| 土默特左旗| 闽清县| 周宁县| 浦县| 遵化市| 永德县| 壶关县| 泉州市| 凤翔县| 福贡县| 宁乡县| 汝南县| 宁远县| 六枝特区| 渭源县| 肇庆市| 福海县| 秦安县| 凤翔县| 安岳县| 延寿县| 喀喇| 仪征市| 固安县| 泸西县| 蒙山县| 喀喇沁旗| 光泽县| 安仁县| 香河县|