1. 缓动曲线:
1 2 3 4 5 6 7 8 9 10 11 | // 示例代码 cc.tween(node) .to(time, { position: newPosition }, { easing: "sineInOut" }) // 先慢后快 .start(); // 常用 easing 类型 // "sineIn" 开始慢,后面加速 // "sineOut" 开始快,后面减速 // "sineInOut" 先慢-加速-再慢 // "quadIn" 二次方曲线加速 // "quadOut" 二次方曲线减速 // "quadInOut" 二次方曲线平滑过渡 |
2. 贝塞尔曲线(Bezier Curve):
1 2 3 4 5 6 7 | //示例代码 cc.tween(node) .bezierTo(time, cc.v2(100, 200), cc.v2(200, 300), cc.v2(300, 100)) // 1秒内按贝塞尔曲线移动 .start(); // bezierTo(time, control1, control2, endPos) // control1 和 control2 是控制点,决定曲线形状。 // endPos 是终点,节点沿着曲线到达该点。 |
3. 分步依次移动,使用 sequence() 组合多个 to():
1 2 3 4 5 6 7 | //示例代码 cc.tween(node) .sequence( cc.tween().to(time1, { position: cc.v2(100, 200) }, { easing: "sineOut" }), cc.tween().to(time2, { position: cc.v2(200, 100) }, { easing: "sineIn" }) ) .start(); |
——
over
转载请注明出处:http://www.jiangkl.com/2025/02/cocos_tween_positin_easing