else if (elementName == "polygon") { // find parent object's dict and add polygon-points to it TMXObjectGroup* objectGroup = _objectGroups.back(); ValueMap& dict = objectGroup->getObjects().rbegin()->asValueMap(); // get points value string std::string value = attributeDict"points"].asString(); if (!value.empty()) { ValueVector pointsArray; pointsArray.reserve(10); // parse points string into a space-separated set of points stringstream pointsStream(value); string pointPair; while(std::getline(pointsStream, pointPair, ' ')) { // parse each point combo into a comma-separated x,y point stringstream pointStream(pointPair); string xStr,yStr; ValueMap pointDict; // set x if(std::getline(pointStream, xStr, ',')) { int x = atoi(xStr.c_str()) + (int)objectGroup->getPositionOffset().x; pointDict"x"] = Value(x); } // set y if(std::getline(pointStream, yStr, ',')) { int y = atoi(yStr.c_str()) + (int)objectGroup->getPositionOffset().y; pointDict"y"] = Value(y); } // add to points array pointsArray.push_back(Value(pointDict)); } dict"points"] = Value(pointsArray); } } ``` 上面是cocos2dx的源码 下面是游戏源码TMXObjectGroup* m_pGroup = map1->objectGroupNamed("object"); auto & m_pObjects = m_pGroup->getObjects(); Dictionary* m_pDict = NULL; Object* m_pObj = NULL; for (auto& obj : m_pObjects) { ValueMap& dict = obj.asValueMap(); float cx = dict"x"].asFloat(); float cy = dict"y"].asFloat(); std::string str = dict"points"].asString(); log("x = %0.f , y = %0.f",cx,cy); log("polygon:%s",str); ``` std::string str = dict"points"].asString(); 报错
你不仔细看的么?
ValueVector pointsArray;
pointsArray.reserve(10);
dict"points"] = Value(pointsArray);
你是什么?
std::string str = dict"points"].asString();
明显应该是
ValueVector pa = dict"points"];
有人吗??????
ValueVector pa = dict"pionts"].asValueVector();
依然报错了