本文整理汇总了C++中FileUtils::getValueMapFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileUtils::getValueMapFromFile方法的具体用法?C++ FileUtils::getValueMapFromFile怎么用?C++ FileUtils::getValueMapFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::getValueMapFromFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: init
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
//////////////////////////////
// 1. super init first
if ( !Layer::init() )
{
return false;
}
FileUtils *fu = FileUtils::getInstance();
ValueMap vm = fu->getValueMapFromFile("data.plist");
log("%s",vm["name"].asString().c_str());
return true;
}
示例2: addShapeWithFileToSprite
void ShapeCache::addShapeWithFileToSprite(std::string plist, cocos2d::Sprite *s){
FileUtils *fu = FileUtils::getInstance();
ValueMap root = fu->getValueMapFromFile(plist);
auto bodies = root["bodies"].asValueMap();
ValueMap fixtureDef;
for (auto iter=bodies.begin(); iter!=bodies.end(); iter++) {
fixtureDef = iter->second.asValueMap();
}
ValueMap item = fixtureDef["fixtures"].asValueVector()[0].asValueMap();
s->setPhysicsBody(PhysicsBody::create());
for (auto iter=item.begin(); iter!=item.end(); iter++) {
std::string key = iter->first;
auto type = iter->second;
if (key == "polygons") {
auto value = type.asValueVector();
for (int i=0; i<value.size(); i++) {
auto _item = value[i].asValueVector();
Vec2 *vec = new Vec2[_item.size()];
for (int j=0; j<_item.size(); j++) {
Point p = PointFromString(_item[j].asString().c_str());
vec[j] = Vec2(p.x, p.y);
}
s->getPhysicsBody()->addShape(PhysicsShapePolygon::create(vec, _item.size()));
}
}else if (key == "mass"){
s->getPhysicsBody()->setMass(type.asInt());
}else if (key == "friction"){
auto shapes = s->getPhysicsBody()->getShapes();
for (int i=0; i<shapes.size(); i++) {
shapes.at(i)->setFriction(type.asInt());
}
}
}
}