Creator 3.0 Preview 移植 Creator 2.4.3 新手上路快速上手:制作第一个游戏遇到的问题

为了体验Creator3.0 Preview做2D游戏,所以移植Creator2.4.3的新手上路 快速上手:制作第一个游戏。添加了资源,设置好场景sprite,添加以下代码
@property
jumpHeight: number = 0;
@property
jumpDuration: number = 0;
@property
maxMoveSpeed: number = 0;
@property
accel: number = 0;

runJumpAction() {
    var jumpUp = tween().by(this.jumpDuration, {y: this.jumpHeight}, {easing: 'sineOut'});
    var jumpDown = tween().by(this.jumpDuration, {y: -this.jumpHeight}, {easing: 'sineIn'});
    var tw = tween().sequence(jumpUp, jumpDown);
    return tween().repeatForever(tw);
}

onLoad () {
    var jumpAction = this.runJumpAction();
    tween(this.node).then(jumpAction).start();
}

发现运行时精灵没有跳动,把代码复制到Creator2.4.3,替换所有tween()为cc.tween(),运行起来是可以正常跳动的。不知道API哪里没有用好。备注:Creator3.0 Preview是禁用了cc,可以直接用tween(),应该不是这个导致问题。

举例:var jumpUp = tween().by(1, {position: new Vec3(0, 1, 0)}, {easing: ‘sineOut’});
这样子就可以正常运行。

正解,替换以下代码就OK了。
var jumpUp = tween().by(this.jumpDuration, {position: new Vec3(0, this.jumpHeight, 0)}, {easing: ‘sineOut’});
var jumpDown = tween().by(this.jumpDuration, {position: new Vec3(0, -this.jumpHeight, 0)}, {easing: ‘sineIn’});
看来从Creator3.0 PreviewAPI的风格也变了。 :rofl:

该主题在最后一个回复创建后7天后自动关闭。不再允许新的回复。