【BUG】Label的cache mode设置为char,文本的描边的透明度有问题。

  • Creator 版本:2.4.4

  • 目标平台: Chrome浏览器

  • 重现方式:
    创建Helloworld工程,添加一个文本节点,设置cache mode为char,给文本添加一个描边组件,在代码里面执行一个淡入淡出的action,随机出现描边的文本的透明度不对。
    项目截图:

主要代码:
const { ccclass, property } = cc._decorator;

@ccclass

export default class Helloworld extends cc.Component {

@property(cc.Label)

label: cc.Label = null;

start() {

    cc.director.getScheduler().schedule(() => {

        this.label.string = Math.floor(Math.random() * 100).toString();

        this.playAction(this.label.node);

    }, this, 5, cc.macro.REPEAT_FOREVER, 1, false);

}

public playAction(target: cc.Node): void {

    let pos = target.position;

    cc.tween(target)

        .parallel(

            cc.tween().to(0.5, { opacity: 255 }),

            cc.tween().to(0.5, { position: cc.v2(pos.x, pos.y + 50) }),

        )

        .delay(1.0)

        .to(0.5, { opacity: 0 })

        .call(() => {

            target.setPosition(pos);

        })

        .start();

}

}

效果图:

说下我的解决方法

引擎版本:2.4.6

修改js引擎中的cocos2d\core\renderer\utils\label\letter-font.js
computeHash方法:
out = out + labelInfo.margin + labelInfo.out.toHEX();
修改为
out = out + labelInfo.margin + labelInfo.out.toHEX(’#rrggbbaa’);

LetterFontAssembler类中的_updateFontFamily方法:
shareLabelInfo.out.a = outline.color.a * comp.node.color.a / 255.0;
修改为
shareLabelInfo.out.a = outline.color.a;

3赞