Cocos 3.3.2 如何利用缓动系统实现顺序动作

请大佬指点下

    SetTouch() {
        this.node.on('touch-start', (event) => {
            if (this.GameType != 1) return
            log('手指按下')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            tween(this.NodeBolickBox).to(2, { scale: new Vec3(1, 0.8, 1) }).start()
            tween(this.NodeBolickShadow).to(2, { scale: new Vec3(0.9, 0.8, 1) }).start()
        }, this);
        this.node.on('touch-move', (event) => {
            if (this.GameType != 1) return
            log('手指移动')
        }, this);
        this.node.on('touch-end', (event) => {
            if (this.GameType != 1) return
            log('手指抬起')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            let Animation_01 = tween(this.NodeBolickBox).to(0.1, { scale: new Vec3(1, 1.1, 1) }).start()
            let Animation_02 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 0.95, 1) }).start()
            let Animation_03 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 1, 1) }).start()
            tween(this.NodeBolickBox).sequence(Animation_01, Animation_02, Animation_03): tween // 报错


            
            tween(this.NodeBolickShadow).to(0.2, { scale: new Vec3(1, 1, 1) }).start()
        }, this);
    }

你现在是什么效果?,需要实现什么样的效果?

1赞

一个Box按下就缩放
当放开我顺序动画:先是缩放然后放大然后缩放,类似果冻Q弹的效果

能看看报错报什么错吗?

1赞

不是报错,是功能实现:
我现在这样写的:

   SetTouch() {
        this.node.on('touch-start', (event) => {
            if (this.GameType != 1) return
            log('手指按下')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            tween(this.NodeBolickBox).to(2, { scale: new Vec3(1, 0.8, 1) }).start()
            tween(this.NodeBolickShadow).to(2, { scale: new Vec3(0.9, 0.8, 1) }).start()
        }, this);
        this.node.on('touch-move', (event) => {
            if (this.GameType != 1) return
            log('手指移动')
        }, this);
        this.node.on('touch-end', (event) => {
            if (this.GameType != 1) return
            log('手指抬起')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            let AnimationBox_01 = tween(this.NodeBolickBox).to(0.1, { scale: new Vec3(1, 1.1, 1) }).start()
            let AnimationBox_02 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 0.95, 1) }).start()
            let AnimationBox_03 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 1, 1) }).start()
            let AnimationBox = new Tween().sequence(AnimationBox_01, AnimationBox_02, AnimationBox_03)

            let AnimationShadow_01 = tween(this.NodeBolickShadow).to(0.1, { scale: new Vec3(1, 1.1, 1) }).start()
            let AnimationShadow_02 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 0.95, 1) }).start()
            let AnimationShadow_03 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 1, 1) }).start()
            let AninmationShadow = new Tween().sequence(AnimationShadow_01, AnimationShadow_02, AnimationShadow_03)


        }, this);
      let Animation_01 = tween(this.NodeBolickBox).to(0.1, { scale: new Vec3(1, 1.1, 1) })
        let Animation_02 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 0.95, 1) })
        let Animation_03 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 1, 1) })
        tween(this.NodeBolickBox).sequence(Animation_01, Animation_02, Animation_03).start()
1赞

你sequence之后少了个start,start相当于运行

1赞

        this.node.on('touch-end', (event) => {
            if (this.GameType != 1) return
            log('手指抬起')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            let AnimationBox_01 = tween(this.NodeBolickBox).to(0.1, { scale: new Vec3(1, 1.1, 1) }).start()
            let AnimationBox_02 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 0.95, 1) }).start()
            let AnimationBox_03 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 1, 1) }).start()
            new Tween().sequence(AnimationBox_01, AnimationBox_02, AnimationBox_03).start()

            let AnimationShadow_01 = tween(this.NodeBolickShadow).to(0.1, { scale: new Vec3(1, 1.1, 1) }).start()
            let AnimationShadow_02 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 0.95, 1) }).start()
            let AnimationShadow_03 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 1, 1) }).start()
            new Tween().sequence(AnimationShadow_01, AnimationShadow_02, AnimationShadow_03).start()


        }, this);

我这样写的但是貌似还不能实现

仔细看看我发的

1赞

你这有问题 你在对比一下

start只要有一个就行

???这?

1赞

哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈哈 :11:

@ai_62po0 @1014602197 感谢两位大佬
解决后:

    SetTouch() {
        this.node.on('touch-start', (event) => {
            if (this.GameType != 1) return
            log('手指按下')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            tween(this.NodeBolickBox).to(2, { scale: new Vec3(1, 0.8, 1) }).start()
            tween(this.NodeBolickShadow).to(2, { scale: new Vec3(0.9, 0.8, 1) }).start()
        }, this);
        this.node.on('touch-move', (event) => {
            if (this.GameType != 1) return
            log('手指移动')
        }, this);
        this.node.on('touch-end', (event) => {
            if (this.GameType != 1) return
            log('手指抬起')
            Tween.stopAllByTarget(this.NodeBolickBox)
            Tween.stopAllByTarget(this.NodeBolickShadow)
            let AnimationBox_01 = tween(this.NodeBolickBox).to(0.1, { scale: new Vec3(1, 1.1, 1) })
            let AnimationBox_02 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 0.95, 1) })
            let AnimationBox_03 = tween(this.NodeBolickBox).to(0.05, { scale: new Vec3(1, 1, 1) })
            //new Tween().sequence(AnimationBox_01, AnimationBox_02, AnimationBox_03).start()
            tween(this.NodeBolickBox).sequence(AnimationBox_01, AnimationBox_02, AnimationBox_03).start()

            let AnimationShadow_01 = tween(this.NodeBolickShadow).to(0.1, { scale: new Vec3(1, 1.1, 1) })
            let AnimationShadow_02 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 0.95, 1) })
            let AnimationShadow_03 = tween(this.NodeBolickShadow).to(0.05, { scale: new Vec3(1, 1, 1) })
            //new Tween().sequence(AnimationShadow_01, AnimationShadow_02, AnimationShadow_03).start()
            tween(this.NodeBolickBox).sequence(AnimationShadow_01, AnimationShadow_02, AnimationShadow_03).start()

        }, this);
    }
1赞

粗心大意了,刚刚改回来了

你这个写法好奇怪,为啥不写成下方这样呢?简洁还好看~

 tween(this.NodeBolickBox)
.to(0.1, { scale: new Vec3(1, 1.1, 1) })
.to(0.05, { scale: new Vec3(1, 0.95, 1) })
.to(0.05, { scale: new Vec3(1, 1, 1) })
.start();

tween(this.NodeBolickShadow)
.to(0.1, { scale: new Vec3(1, 1.1, 1) })
.to(0.05, { scale: new Vec3(1, 0.95, 1) })
.to(0.05, { scale: new Vec3(1, 1, 1) })
.start();
1赞

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