1. 程式人生 > >cocos2dx中讀取.plist檔案方法

cocos2dx中讀取.plist檔案方法

//獲取Chinese.plist的相對路徑
std::string testPlistPath = "images\\Chinese.plist";
//獲取Chinese.plist的絕對路徑
std::string f1 = FileUtils::getInstance()->fullPathFromRelativeFile(
"Chinese.plist", testPlistPath);
//判斷路徑檔案是否存在
if (FileUtils::getInstance()->isFileExist(f1)) {
auto lo = __Dictionary::createWithContentsOfFile(f1.c_str());

auto che = (__Dictionary *) lo->objectForKey("chess");
auto a = (__Dictionary *) che->objectForKey("1");
auto intValue = (__String *) a->objectForKey("x4");
x14 = intValue->intValue();