其中关于tween 动画的官方教程编写如下:
` // 跳跃上升
var jumpUp = cc.tween().by(this.jumpDuration, {y: this.jumpHeight}, {easing: 'sineOut'});
// 下落
var jumpDown = cc.tween().by(this.jumpDuration, {y: -this.jumpHeight}, {easing: 'sineIn'});
// 创建一个缓动,按 jumpUp、jumpDown 的顺序执行动作
var tween = cc.tween().sequence(jumpUp, jumpDown)
// 不断重复
return cc.tween().repeatForever(tween);`
我在3.3.0上的使用TS编写后,没有报错,但是没有动画效果。我写的代码如下:
`
private runJumpAction(){
log("跳跃的高度"+this.jumpHeight);
var jumpUp = tween().by(this.jumpDuration,{y:this.jumpHeight},{easing:"sineOut"})
var jupmDown = tween().by(this.jumpDuration,{y:-this.jumpHeight},{easing:"sineIn"})
var action = tween().sequence(jumpUp,jupmDown)
return tween().repeatForever(action);
}
onLoad(){
var action = this.runJumpAction();
log(this.node.name);
tween(this.node).then(action).start();
}
`