为了体验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(),应该不是这个导致问题。
