請問在使用position設定位置時,2.4.5版還能單純設定x or y or z的單值,在3.0後好像被改掉了,只能輸入Vec3。有其他方法可以設定單值的嗎?先謝謝了
tween(this.node)
.by(this.jumpDuration,{position: new Vec3(0,this.jumpHeight,0)},{easing: "cubicInOut"})
.by(this.jumpDuration,{position: new Vec3(0,-this.jumpHeight,0)},{easing: "cubicIn"})
.call(()=>{
this.playJumpSound();
})
.union()
.repeatForever()
.start()
以上如果跟控制左右移動的代碼同時運行,因為又不能單純設定x or y or z的單值,只能用到setPosition的方法
update (dt:number) {
if (this.accLeft) {
this.xSpeed -= this.accel * dt;
}
else if (this.accRight) {
this.xSpeed += this.accel * dt;
}
var nodeX = this.node.getPosition().x;
nodeX += this.xSpeed * dt;
var nodeY = this.node.getPosition().y;
var newPos = v3(nodeX,nodeY,0);
this.node.setPosition(newPos);
}
感覺好像會衝突,舊版本用action就沒事,2.4.5用tween也沒事