Plist格式属于XML文件,用于通常用于储存用户设置,也可以用于存储捆绑的信息。为避免我们在写程序时候写死,方便以后的测试修改工作,我们常常需要用.plist文件存储用户设置等信息,类似的还有粒子效果,瓦片地图等,使用TexturePacker,Particle Designer图片工具打包小图片时,就会生成一个pilst文件。
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
使用实例:
string MyUitility::getUTF8Char(const string key)
{
auto SharedFileUtils = FileUtils::getInstance();
std::string fullPathForFilename = SharedFileUtils->fullPathForFilename("utf8_char.plist");
bool isExist = false;
isExist= SharedFileUtils->isFileExist(fullPathForFilename);
if (!isExist)
{
log("utf8_char.plist no ");
return "";
}
ValueMap map= SharedFileUtils->getValueMapFromFile(fullPathForFilename);
Value Value = map[key];
return Value.asString();
}
auto txtTest = Label::createWithTTF(MyUtility::getUTF8Char("test"), "fonts/hanyi.ttf", 18);
txtTest->setColor(Color3B(14,83,204));
txtTest->setPosition(95, top->getPosition().y - 70);
txtTest->setAnchorPoint(Vec2(0,0));
addChild(txtTest, 1);
注:使用的是关东升老师的《Cocos2d-x实战 c++》中的代码。