在用cocos2dx是遇到了cocos2dx lablettf 描边错乱的问题,就像下面。下面是出错代码。
function createTextFieldBySize(str_label, width, font_size,  x, y, point)
local label = cc.Label:createWithTTF(str_label, "fonts/chinese.ttf", font_size)
label:setTextColor(cc.c4b(0xFF, 0xFF, 0xFF, 0xFF))
label:enableOutline(cc.c4b(0x5F, 0x30, 0x1E, 0xFF), 2)
label:enableGlow(cc.c4b(1, 42, 67, 255))
if point ~= nil then
label:setAnchorPoint(point)
end
if width ~= nil then
local label_width = label:getContentSize().width
local label_height = label:getContentSize().height
if label_width > width then
local line_num = math.ceil(label_width/width)
label:setContentSize(cc.size(width, label_height*line_num))
label:setWidth(width)
-- label:setHeight(label_height*line_num)
end
end
if x ~= nil and y ~= nil then
label:setPosition(cc.p(x, y))
end
return label
end
把这句去掉就不会乱掉

label:enableOutline(cc.c4b(0x5F, 0x30, 0x1E, 0xFF), 2)

cocos2dx lablettf 描边错乱

描边错乱

cocos2dx lablettf 描边错乱

去掉描边

       在网上找了一下,有些朋友说可以先初始化一下,就像这样
初始化方法如下:
TTFConfig ttfConfig("PixelMplus12-Bold.ttf",20,GlyphCollection::DYNAMIC);
ttfConfig.customGlyphs = nullptr;
descripLabel = Label::createWithTTF(ttfConfig, textString);
descripLabel->setTextColor(Color4B(Color3B(0x33,0x33,0x33)));
descripLabel->enableOutline(Color4B(Color3B(0xff,0xff,0xff)),2.0);
descripLabel->setLineHeight(35.0f);
descripLabel->setDimensions(550, 100);
       不过最有效的方法还是换成3.2的版本,就不会出现这种问题了。