缓动系统Y轴动画时,无法更新x轴坐标

`

cc.Class({

extends: cc.Component,

properties: {
    // 主角跳跃高度
    jumpHeight: 0,
    // 主角跳跃持续时间
    jumpDuration: 0,
    // 最大移动速度
    maxMoveSpeed: 0,
    // 加速度
    accel: 0,
    // foo: {
    //     // ATTRIBUTES:
    //     default: null,        // The default value will be used only when the component attaching
    //                           // to a node for the first time
    //     type: cc.SpriteFrame, // optional, default is typeof default
    //     serializable: true,   // optional, default is true
    // },
    // bar: {
    //     get () {
    //         return this._bar;
    //     },
    //     set (value) {
    //         this._bar = value;
    //     }
    // },
},

// LIFE-CYCLE CALLBACKS:

onLoad () {
    // 初始化跳跃动作
    cc.tween(this.node)
    .repeatForever(
        cc.tween(this.node)
        .by(this.jumpDuration, {position: cc.v2(0, this.jumpHeight)}, {easing: 'cubicOut'})
        .by(this.jumpDuration, {position: cc.v2(0, -this.jumpHeight)}, {easing: 'cubicIn'})
    )
    .start();
    // 加速度方向开关
    this.accLeft = false;
    this.accRight = false;
    // 主角当前水平方向速度
    this.xSpeed = 0;
    // 初始化键盘输入监听
    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
    cc.systemEvent.on(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
},

start () {
    
},

onKeyDown (event) {
    // set a flag when key pressed
    switch(event.keyCode) {
        case cc.macro.KEY.a:
            this.accLeft = true;
            break;
        case cc.macro.KEY.d:
            this.accRight = true;
            break;
    }
},

onKeyUp (event) {
    // unset a flag when key released
    switch(event.keyCode) {
        case cc.macro.KEY.a:
            this.accLeft = false;
            break;
        case cc.macro.KEY.d:
            this.accRight = false;
            break;
    }
},

onDestroy () {
    // 取消键盘输入监听
    cc.systemEvent.off(cc.SystemEvent.EventType.KEY_DOWN, this.onKeyDown, this);
    cc.systemEvent.off(cc.SystemEvent.EventType.KEY_UP, this.onKeyUp, this);
},

update (dt) {
    // 根据当前加速度方向每帧更新速度
    if (this.accLeft) {
        this.xSpeed -= this.accel * dt;
    } else if (this.accRight) {
        this.xSpeed += this.accel * dt;
    }
    // 限制主角的速度不能超过最大值
    if ( Math.abs(this.xSpeed) > this.maxMoveSpeed ) {
        // if speed reach limit, use max speed with current direction
        this.xSpeed = this.maxMoveSpeed * this.xSpeed / Math.abs(this.xSpeed);
    }
    // 根据当前速度更新主角的位置
    this.node.x += this.xSpeed * dt;
},
});

`
萌新一枚,上面这段代码,无法左右移动,但是老版本的Action是可以移动的,可是Action过期了,请问哪位大佬有解决办法吗?

找到办法了,直接设置{y:this.jumpHeight}

可以左右移动了吗?你设置y:this.jumpHeight改变不了x轴吧,我也是这个问题,在tween动画之中不能改变node值,旧版的Action是可以的,请问怎么解决这个问题…?