dictionary with cocos2d-x 3.0-Beta

dictionary with cocos2d-x 3.0-Beta
0.0 0


i wonder what would be the best way to convert this code to cocos2d-x 3beta … i am not sure how to do that without using cocos2d dictionary … what is the best cocos2d-x/c++ practice for this :

std::string path = FileUtils::getInstance()>fullPathForFilename;
Dictionary* levelsDict = Dictionary::createWithContentsOfFileThreadSafe);
String* levelNb = String::createWithFormat;
Dictionary* lvlDict = levelsDict



I’d also like to know the answer to this.

I’ve spent some time looking at other possible solutions, like RapidJSON, but without too much luck and it’s not my preferred method, as I already have a bunch of PLIST files I’d like to keep.


As far as I understand, you are stuck on loading the dictionary from the file? If so, then try using FileUtils::getValueMapFromFile().


Something like that should work:

std::string path = FileUtils::getInstance()->fullPathForFilename("levels.plist");
ValueMap levelsDict = FileUtils::getInstance()->getValueMapFromFile(path);
std::string levelNb = "stage" + std::to_string(stage) + "_level" + std::to_string(level);
ValueMap lvlDict = levelsDict.at(levelNb).asValueMap();


Thanks very much dot squid and Oleg!


Thanks Guys