Skip to content

Commit 9111e81

Browse files
committed
Merge pull request cocos2d#1846 from VisualSJ/develop-canvasLabelTTF
Closed #5157: Fix - LabelAtlas use setString will clear everything in ca...
2 parents d18be50 + 453b1d0 commit 9111e81

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

cocos2d/labels/CCLabelAtlas.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{
182182
}
183183
},
184184

185+
_addChildForCanvas: function(child, zOrder, tag){
186+
child._lateChild = true;
187+
cc.NodeRGBA.prototype.addChild.call(this, child, zOrder, tag);
188+
},
189+
185190
/**
186191
* @function
187192
* Atlas generation
@@ -210,7 +215,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{
210215
} else
211216
fontChar.initWithTexture(texture, rect);
212217

213-
this.addChild(fontChar, 0, i);
218+
cc.NodeRGBA.prototype.addChild.call(this, fontChar, 0, i);
214219
} else {
215220
if (c == 32) {
216221
fontChar.init();
@@ -319,7 +324,7 @@ cc.LabelAtlas = cc.AtlasNode.extend(/** @lends cc.LabelAtlas# */{
319324
len = locChildren.length;
320325
for (var i = 0; i < len; i++) {
321326
var node = locChildren[i];
322-
if (node)
327+
if (node && !node._lateChild)
323328
node.visible = false;
324329
}
325330
}
@@ -370,6 +375,7 @@ if (cc._renderType === cc._RENDER_TYPE_WEBGL) {
370375
_p.updateAtlasValues = _p._updateAtlasValuesForCanvas;
371376
_p.setString = _p._setStringForCanvas;
372377
_p.setOpacity = _p._setOpacityForCanvas;
378+
_p.addChild = _p._addChildForCanvas;
373379
}
374380

375381
// Override properties

0 commit comments

Comments
 (0)