增加 BezierTo贝尔曲线,JumpTo 建议把这个加上 3.0上没有这些了
大佬们你们用新动作tween,用不了BezierTo了
把之前的新增进去就行了,不过不合适3d。
declare module “cc” {
interface Tween {
bezierTo: (duration: number, c1: Vec3, c2: Vec3, to: Vec3) => Tween;
}
}
Object.assign(Tween.prototype, {
/**
* !#en Sets target’s position property according to the bezier curve.
* !#zh 按照贝塞尔路径设置目标的 position 属性。
* @method bezierTo
* @param {number} duration
* @param {cc.Vec2} c1
* @param {cc.Vec2} c2
* @param {cc.Vec2} to
* @return {Tween}
* @typescript bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2): Tween
*/
bezierTo(duration, c1, c2, to, opts) {
let c0x = c1.x, c0y = c1.y,
c1x = c2.x, c1y = c2.y;
let x = 0;
opts = opts || Object.create(null);
opts.progress = function (start, end, current, t) {
if (x > 1) x = 0;
if (x == 0) {
x++;
return bezier(start, c0x, c1x, end, t);
}
else if (x == 1) {
x++;
return bezier(start, c0y, c1y, end, t);
}
}
return this.to(duration, { position: to }, opts);
}
}