Quantcast
Channel: Cocos中文社区 - 最新帖子
Viewing all articles
Browse latest Browse all 494966

ttf字体在游戏中经常显示不全!!!文字在字库中存在

$
0
0

在CCLabel.cpp文件中加几行代码

void Label::setFontAtlas(FontAtlas* atlas,bool distanceFieldEnabled /* = false /, bool useA8Shader / = false */)
{
if (atlas == _fontAtlas)
{
FontAtlasCache::releaseFontAtlas(atlas);
return;
}

if (_fontAtlas)
{
    FontAtlasCache::releaseFontAtlas(_fontAtlas);
    _fontAtlas = nullptr;
}

_fontAtlas = atlas;

if (_textureAtlas)
{
    _textureAtlas->setTexture(_fontAtlas->getTexture(0));
}
else
{
    SpriteBatchNode::initWithTexture(_fontAtlas->getTexture(0), 30);
}

//--------------------------------这里是新添加的-----------------------
if (_batchNodes.size() > 1)
{
_batchNodes.clear();
batchNodes.pushback(this);
}
//----------------------------------------------------------------
if (_reusedLetter == nullptr)
{
_reusedLetter = Sprite::create();
reusedLetter->setOpacityModifyRGB(isOpacityModifyRGB);
_reusedLetter->retain();
reusedLetter->setAnchorPoint(Vec2::ANCHORTOP_LEFT);
}
_reusedLetter->setBatchNode(this);

if (_fontAtlas)
{
    _commonLineHeight = _fontAtlas->getCommonLineHeight();
    _contentDirty = true;
}
_useDistanceField = distanceFieldEnabled;
_useA8Shader = useA8Shader;

if (_currentLabelType != LabelType::TTF)
{
    _currLabelEffect = LabelEffect::NORMAL;
    updateShaderProgram();
}

}


Viewing all articles
Browse latest Browse all 494966

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>