如何访问嵌套的plist目录cocos2dx?

How to access nested plist directories cocos2dx?

我是编程新手,无法访问嵌套在其他目录中的目录。如有任何建议,我们将不胜感激。

示例: Nested Dir

我用来访问第一个目录的 Cocos2dx 代码:

__String *fileName = __String::create( "InventoryData.plist" );

__Dictionary *dictionary = __Dictionary::createWithContentsOfFile(fileName->getCString() );

我试过使用 __Dictionary::createWithDirectory("Nested Root") 但那行不通,因为找不到它。我确定有一种简单的方法可以做到这一点,但我似乎找不到它。对不起,菜鸟问题。

使用这个遍历字典的微CCDICT_FOREACH(__dict__, __el__)

__Dictionary *dist=__Dictionary::createWithContentsOfFile("xyz.plist");

DictElement *d=nullptr;
CCDICT_FOREACH(dist, d){

  CCLOG("%s",d->getStrKey());  // It will print all key name

  if(*d->getStrKey()==*"texture"){  //Match with particular Key(here I'm using texture)

       __Dictionary *nested=(__Dictionary*)d->getObject();  // downcast nested dictionary.

       // Now you've nested dictionary you can get value or if having nested dictionary iterate again

       CCLOG("%s",nested->valueForKey("width")->getCString());  
       CCLOG("%s",nested->valueForKey("height")->getCString());  

   }
}