假设fnt 里有1000个字,每创建一个文字都会生成1000个FontAtlas,在_updateFontScale个函数里 ,临时改了下
_updateFontScale:function(){E=b/S},_updateProperties:function()
{
var t=h.font;
if(!window.global_fontatlas){
window.global_fontatlas={};
console.log(‘global_fontatlas init’);
}
C=t.spriteFrame;
m=t._fntConfig;
if(window.global_fontatlas[h.font._name] )
{
h._fontAtlas=p=window.global_fontatlas[h.font._name];
}
else
{
if(!(p=h._fontAtlas))
{
p=new cc.FontAtlas(m);
var e=m.fontDefDictionary;
for(var i in e)
{
var n=new a,s=e[i].rect;n._offsetX=e[i].xOffset,n._offsetY=e[i].yOffset,n._width=s.width,n._height=s.height,n._u=s.x,n._v=s.y,n._textureID=0,n._validDefinition=!0,n._xAdvance=e[i].xAdvance,p.addLetterDefinitions(i,n)
}
window.global_fontatlas[h.font._name]=h._fontAtlas=p
}
}
A=h.string.toString(),b=h.fontSize,S=m.fontSize,w.width=h.node._contentSize.width,w.height=h.node._contentSize.height,M=h.horizontalAlign,R=h.verticalAlign,D=h.spacingX,L=h.overflow,I=h._lineHeight,O=L!==r.NONE&&(L===r.RESIZE_HEIGHT||h.enableWrapText),this._setupBMFontOverflowMetrics()
}