2dx3.3+ccs1.6
编辑器里的Text,在代码里enableShadow会丢失颜色
初步研究了一下,原因是reader没设置setTextColor只是设置了setColor,所以在enableShadow的时候找不到textColor
初步找了一个改法(这只是一个初步修改方案,只供参考思路,我自己测试可行,悲剧了别找我!)
TextReader.cpp145行位置插入两行代码,设置setTextColor
void TextReader::setPropsFromJsonDictionary(Widget *widget, const rapidjson::Value &options)
{
WidgetReader::setPropsFromJsonDictionary(widget, options);
std::string jsonPath = GUIReader::getInstance()->getFilePath();
Text* label = static_cast<Text*>(widget);
bool touchScaleChangeAble = DICTOOL->getBooleanValue_json(options, P_TouchScaleEnable);
label->setTouchScaleChangeEnabled(touchScaleChangeAble);
const char* text = DICTOOL->getStringValue_json(options, P_Text,"Text Label");
label->setString(text);
label->setFontSize(DICTOOL->getIntValue_json(options, P_FontSize,20));
std::string fontName = DICTOOL->getStringValue_json(options, P_FontName, "");
std::string fontFilePath = jsonPath.append(fontName);
if (FileUtils::getInstance()->isFileExist(fontFilePath))
{
label->setFontName(fontFilePath);
}
else{
label->setFontName(fontName);
}
bool aw = DICTOOL->checkObjectExist_json(options, P_AreaWidth);
bool ah = DICTOOL->checkObjectExist_json(options, P_AreaHeight);
if (aw && ah)
{
Size size = Size(DICTOOL->getFloatValue_json(options, P_AreaWidth),DICTOOL->getFloatValue_json(options,P_AreaHeight));
label->setTextAreaSize(size);
}
bool ha = DICTOOL->checkObjectExist_json(options, P_HAlignment);
if (ha)
{
label->setTextHorizontalAlignment((TextHAlignment)DICTOOL->getIntValue_json(options, P_HAlignment));
}
bool va = DICTOOL->checkObjectExist_json(options, P_VAlignment);
if (va)
{
label->setTextVerticalAlignment((TextVAlignment)DICTOOL->getIntValue_json(options, P_VAlignment));
}
WidgetReader::setColorPropsFromJsonDictionary(widget, options);
const Color3B &color = label->getColor();
label->setTextColor(Color4B(color.r, color.g, color.b, 255));
}