cocos 3.8.2 Label.color属性是tween中修改时闪动

  • Creator 版本: 3.8.2

  • 目标平台: windows10 chrome中看到闪动现象

  • 重现方式:
    目标》通过修改节点.控件.颜色.a属性来使Label在一秒只变透明,
    但事与愿违没有变透明,只是在闪动!!

使用以下代码重现:
let complabel= labelNode.getComponent(Label);

  let startColor = complabel.color; // 获取当前颜色  
  let endColor = (startColor).clone(); // 这是.color是竟然是只读的,官方能否不让它只读
  endColor.a =0;

  tween(complabel)  
      .to(0.9, { color: endColor}) // 使用 to 来设置结束值  
      .start();
  • 首个报错:
    cocos 3.8.2 Label.color属性是tween中修改时闪动

  • 重现概率:1000%

请问高手怎么办!!

添加 UIOpacity组件,修改该组件的Opacity属性,从255-0

 /**
 * @en Convert the given color to a hex color value. And save the results to out color.
 * @zh 获取指定颜色的整型数据表示
 */
public static hex<Out extends IColorLike> (a: Out) {
    return ((a.r * 255) << 24 | (a.g * 255) << 16 | (a.b * 255) << 8 | a.a * 255) >>> 0;
}

因为它他是16进制的一个数存的
你可以这样做

 tween(block.getComponent(Sprite)).to(10,{}, {
     onUpdate: (target: object, ratio: number)=>{
         target['color'] = new Color(255,255 - ratio * 255,0);
     }
 }).start();
1赞