Gui*_*rme 1 plist cocos2d-x cocos2d-x-3.0
我有这个plist文件:
<?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">
<key>levels</key>
<array>
<dict>
<key>x</key>
<int>80</int>
<key>y</key>
<int>266</int>
</dict>
<dict>
<key>x</key>
<int>170</int>
<key>y</key>
<int>266</int>
</dict>
</array>
</plist>
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用cocos2dx v3.2读取该文件:
ValueMap data;
std::string path = FileUtils::getInstance()->fullPathForFilename("my.plist");
data = FileUtils::getInstance()->getValueMapFromFile(path);
auto arrLevels = data.at("levels").asValueVector();
for(int i = 0; i < arrLevels.capacity(); i++){
//I don't know what I have to do here to get the x value and y value of the current item.
}
Run Code Online (Sandbox Code Playgroud)
有人可以帮我吗?我正在所有互联网中搜索,为此发现的所有示例均不足。
用这个;
ValueMap data;
std::string path = FileUtils::getInstance()->fullPathForFilename("my.plist");
data = FileUtils::getInstance()->getValueMapFromFile(path);
auto arrLevels = data.at("levels").asValueVector();
for (int i = 0; i<arrLevels.size(); i++) {
ValueMap sdata = (arrLevels[i]).asValueMap();
int x = sData["x"].asInt();
int y = sData["y"].asInt();
}
Run Code Online (Sandbox Code Playgroud)