如何指定停止 stop cc.tween()

  • Creator 版本: 2.3.3

  • 目标平台: WEB

如標題 不知道如何停止特定的緩動 官方沒寫大家都怎麼試出來的?

runblinktext(num){
    var parent= this.node.getChildByName("parent");
        cc.tween(parent.children[num])
        .repeatForever(
            cc.tween()
            .to(0.5, { opacity: 0 })
            .to(0.5, { opacity: 255 })
        )
        .start()
        cc.Tween.tag = 1313
    },

stopblinktext(){
    cc.Tween.stopAllByTarget(1313);
    var parent= this.node.getChildByName("parent");
    for (let index = 0; index < parent.children.length; index++) {
        const element = rate.children[index];
        element.opacity = 255;
    }
},
1赞

cc.Tween.tag = 1313????
这不是个对象方法吗?你怎么用成静态方法了!

1赞
startTween() {
    this.myTween = cc.tween(this.tweenNode)
        .repeatForever(
            cc.tween()
                .to(0.5, { opacity: 0 })
                .to(0.5, { opacity: 255 })
        ).start();
},
stopTween() {
    this.myTween.stop();
    // this.tweenNode.stopAllActions(); //action的停止方法,也能停止tween
},

这是我通常的写法,你可以参考下。
有一点疑问?parent.children[num] ,每个child都做同步的动作,为什么不父节点做动作呢?

1赞
cc.tween(this.node).tag(1).to(3, {scale: 10}).to(3, {scale: 1}).start();
this.scheduleOnce(()=>{
     cc.Tween.stopAllByTag(1);
},1);

可以这样写

2赞

var twn = cc.tween(parent.children[num])
.repeatForever(
cc.tween()
.to(0.5, { opacity: 0 })
.to(0.5, { opacity: 255 })
)
.start()
twn.stop()

很多时候不希望定义太多变量

很多时候我连代码都不想写`~~~

我應該是寫錯了 不太會應用 應該加上num在後面

感謝 這方法是可行 但是會需要this很多個 父節點底下閃爍的字太過於多 才想要使用TAG看看

請問那設定TAG的正確寫法一班都怎麼寫?

因為會在不同的function 中執行他停止 所以才想要用TAG

it is best way i guess. thanks worked for me too.

好用! 感谢!666