欢迎光临散文网 会员登陆 & 注册

CocosCreator关于tween(target).stop在某些场景下失效的解决方案

2022-01-11 11:28 作者:会飞的蜗牛007  | 我要投稿

bug实例:

startani(){

        tween(this.grayBg.getComponent(UIOpacity)).repeatForever(

        tween().to(0.5,{opacity:150})

        .to(0.5,{opacity:255})

        .delay(1)

        ).start();

}

stopAni(){

            tween(this.grayBg.getComponent(UIOpacity)).stop();

}

以上没有效果!!! 并不能停止节点运动

API没查到,网上有说没有保存tween的实例,做了一下修改,确实可以停止了。。。那stop的api不是有问题么。而且大部分情况下是有效的啊。

贴一下不生效的解决方案:

startAni(){

            this._graybgAni = tween(this.grayBg.getComponent(UIOpacity)).repeatForever(

            tween().to(0.5,{opacity:150})

            .to(0.5,{opacity:255})

            .delay(1)

            ).start();

}

stopAni(){

            

            if(this._graybgAni)this._graybgAni.stop();

            

            this.grayBg.getComponent(UIOpacity).opacity = 255;

}


CocosCreator关于tween(target).stop在某些场景下失效的解决方案的评论 (共 条)

分享到微博请遵守国家法律