Skip to content

Commit 94144e3

Browse files
caryliu1999jareguo
authored andcommitted
Fix the problem that Label switch CacheMode is invalid in Editor. (cocos#5493)
* Fix the problem that Label switch CacheMode is invalid in Editor. * modify by comment
1 parent daafbac commit 94144e3

4 files changed

Lines changed: 14 additions & 6 deletions

File tree

cocos2d/core/components/CCLabel.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -488,7 +488,9 @@ let Label = cc.Class({
488488
if (oldValue === CacheMode.CHAR) {
489489
this._ttfTexture = null;
490490
}
491-
491+
492+
this._resetAssembler();
493+
this._applyFontTexture(true);
492494
this._lazyUpdateRenderData();
493495
},
494496
animatable: false

cocos2d/core/renderer/webgl/assemblers/label/2d/bmfont.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,9 @@ export default class WebglBmfontAssembler extends BmfontAssembler {
5858
_dataOffset = 0;
5959
}
6060

61-
updateColor () {}
61+
_getColor (comp) {
62+
return comp.node._color._val;
63+
}
6264

6365
appendQuad (comp, texture, rect, rotated, x, y, scale) {
6466
let renderData = this._renderData;
@@ -72,7 +74,7 @@ export default class WebglBmfontAssembler extends BmfontAssembler {
7274
texh = texture.height,
7375
rectWidth = rect.width,
7476
rectHeight = rect.height,
75-
color = comp.node._color._val;
77+
color = this._getColor(comp);
7678

7779
let l, b, r, t;
7880
let floatsPerVert = this.floatsPerVert;

cocos2d/core/renderer/webgl/assemblers/label/2d/letter.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,13 @@ export default class WebglLetterFontAssembler extends LetterFontAssembler {
3333
return comp.requestRenderData();
3434
}
3535

36+
_getColor (comp) {
37+
WHITE._fastSetA(comp.node._color.a);
38+
return WHITE._val;
39+
}
40+
3641
updateColor (comp) {
37-
WHITE._fastSetA(comp.node.color.a);
38-
let color = WHITE._val;
42+
let color = this._getColor(comp);
3943

4044
super.updateColor(comp, color);
4145
}

cocos2d/core/renderer/webgl/assemblers/label/2d/ttf.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ export default class WebglTTFAssembler extends TTFAssembler {
4343
}
4444

4545
updateColor (comp) {
46-
WHITE._fastSetA(comp.node.color.a);
46+
WHITE._fastSetA(comp.node._color.a);
4747
let color = WHITE._val;
4848

4949
super.updateColor(comp, color);

0 commit comments

Comments
 (0)