最美情侣中文字幕电影,在线麻豆精品传媒,在线网站高清黄,久久黄色视频

歡迎光臨散文網(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ó)家法律
仙游县| 莲花县| 林甸县| 来安县| 临沂市| 广东省| 云林县| 射阳县| 从化市| 迁西县| 巫溪县| 滨州市| 石屏县| 民权县| 贺兰县| 丰城市| 寿宁县| 双牌县| 原平市| 武强县| 息烽县| 黄浦区| 永顺县| 宝山区| 乐东| 农安县| 锦屏县| 元氏县| 卢龙县| 鸡泽县| 遵义市| 长治市| 尼玛县| 桓台县| 巨野县| 高台县| 斗六市| 柘荣县| 安泽县| 和静县| 三台县|