请问一下3.0里面移除了action那如果想用类似jumpto的效果是不是要自己实现了?我看示例和api都没有找找到类似的实现。
同问, 难搞。升级2.4.3到3以上都难的要命
版本2.4.2
模拟了一个近似的效果,效果没有cc.jump好,没有细调,你看能不能满足你的需求:
jumpTo (t: number, spos: cc.Vec2, epos: cc.Vec2, height: number, times: number = 1) {
times = Math.round(Math.max(times, 1)); // 最小为1 四舍五入取整
let tween = cc.tween();
tween.set({x: spos.x, y: spos.y});
let lastPos = spos;
for (let i=0; i<times; ++i) {
let p = cc.v2();
p.x = lastPos.x + (epos.x - spos.x) / times;
p.y = lastPos.y + (epos.y - spos.y) / times;
let m = cc.v2();
m.x = (p.x + lastPos.x) / 2;
m.y = Math.max(p.y, lastPos.y) + height * 2;
tween.then(cc.tween().bezierTo(t / times, lastPos, m, p, {easing: 'sineInOut'}));
lastPos = p;
}
tween.union();
return tween;
}
测试使用:
let jump2 = this.jumpTo(3, this.test2.getPosition(), cc.v2(500, 300), 100, 4); jump2.clone(this.test2).start();
如果需要贝塞尔缓动的话,需要creator.d.ts需要把参数暴露出来:
/**
!#en Sets target’s position property according to the bezier curve.
!#zh 按照贝塞尔路径设置目标的 position 属性。
@param duration duration
@param c1 c1
@param c2 c2
@param to to
/
bezierTo(duration: number, c1: Vec2, c2: Vec2, to: Vec2, opts?): Tween;
/*
!#en Sets target’s position property according to the bezier curve.
!#zh 按照贝塞尔路径设置目标的 position 属性。
@param duration duration
@param c1 c1
@param c2 c2
@param to to
*/
bezierBy(duration: number, c1: Vec2, c2: Vec2, to: Vec2, opts?): Tween;
嗯, 我试试, 有劳您了。
客气了
大佬6p,mark先
感谢,灰常好用。
牛逼!unity转过来的,见到救星了 
马斯克!!!
大佬有贝塞尔曲线的吗?cocos3.8版本
mark就是拥有
请问大佬为何报这个错误呢?
你查看下这个opts为啥是个 undefined