工程Resource目录创建一个Chinese.plist文件:
注意.plist文件最好用notepad的utf-8格式编写
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"/>
<plist version="1.0">
<dict>
<key>z_bh</key>
<string>编号显示</string>
</dict>
<dict>
<key>z_mc</key>
<string>名称显示</string>
</dict>
</plist>
需要使用中文的地方代码:
auto value_map = FileUtils::getInstance()->getValueMapFromFile("Chinese.plist");//引用Chinese.plist文件
std::string info1 = value_map.at("z_mc").asString();
std::string info2 = value_map.at("z_bh").asString();
auto label_1 = Label::createWithSystemFont(info1, "微软雅黑", 25);
auto label_2 = Label::createWithSystemFont(info2, "微软雅黑", 25);
label_1->setPosition(Vec2(185,670));
label_2->setPosition(Vec2(185,640));
this->addChild(label_1,2);//第二个是设置优先级
this->addChild(label_2,2);