- Creator 版本: 2.4
效果如下:上半部分没有使用同步,下半部分是同步后的效果
扩展如下:以插件脚本的形式对cc.Tween.start进行扩展
let oldStart = cc.Tween.prototype.start;
cc.Tween.prototype.start = function(time) {
oldStart.call(this);
//同步时间
if (time !== undefined && time !== null && this._finalAction instanceof cc.ActionInterval) {
let action = this._finalAction;
let t = (cc.sys.now() - time) * 0.001;
if (this._finalAction instanceof cc.RepeatForever) {
action = this._finalAction.getInnerAction();
t %= action.getDuration();
} else if (action._timesForRepeat > 1) {
t %= action.getDuration();
}
action._elapsed = t;
action._firstTick = false;
action.step(0);
}
return this;
}
用法:使用的时候传入一个相同的同步时间
let time = cc.sys.now();
this.schedule(() => {
let node = cc.instantiate(this.n);
node.parent = this.node;
node.y = - cc.winSize.height * 0.25;
node.x = 100 * count2++ - cc.winSize.width * 0.5;
cc.tween(node).
by(2, { y: 100 }, { easing: "cubicOut" }).
by(2, { y: -100 }, { easing: "cubicOut" }).
union().
repeatForever().
start(time);
}, 1, 9, 0.01);
代码报红:使用的时候start会报红,可以修改.d.ts文件

