本文整理汇总了C++中JSONValue::Child方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::Child方法的具体用法?C++ JSONValue::Child怎么用?C++ JSONValue::Child使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JSONValue
的用法示例。
在下文中一共展示了JSONValue::Child方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: string
Manager::Manager() :
env( SDL_putenv(const_cast<char*>("SDL_VIDEO_CENTERED=center")) ),
jgdata( JSONGamedata::getInstance() ),
io( IOManager::getInstance() ),
clock( Clock::getInstance() ),
screen( io.getScreen() ),
worlds(),
viewport( Viewport::getInstance() ),
explosions(),
sprites(),
player(jgdata.getStr("player.name")),
currentSprite(0),
TICK_INTERVAL(jgdata.getInt("fpsController.tickInterval")),
nextTime(clock.getTicks()+TICK_INTERVAL)
{
clock.pause();
if (SDL_Init(SDL_INIT_VIDEO) != 0) {
throw string("Unable to initialize SDL: ");
}
atexit(SDL_Quit);
JSONValue* backs = jgdata.getValue("backgrounds");
unsigned int numbacks = backs->CountChildren();
std::cout << "Loading " << numbacks << " backgrounds" << std::endl;
for(unsigned i = 0; i < numbacks; i++){
std::string name = backs->Child(i)->Child("name")->AsString();
int fact = 1;
if (backs->Child(i)->HasChild("fact"))
fact = backs->Child(i)->Child("fact")->AsNumber();
worlds.push_back( World(FrameFactory::getInstance().getFrame(name), fact) );
}
unsigned int n = jgdata.getInt("triForce.num");
float smin = jgdata.getFloat("triForce.scale.min");
float smax = jgdata.getFloat("triForce.scale.max");
sprites.reserve(n+2);
for(unsigned i = 0; i < n; i++){
sprites.push_back(new Sprite("triForce",smin,smax));
}
explosions.push_back(new TwowayMultiframeSprite("Etank"));
sort(sprites.begin(), sprites.end());
viewport.setObjectToTrack(player.getSprite());
}
示例2: loadFile
int LevelManager::loadFile(const std::string& file) {
JSONValue *fileData = JSON::Parse(file);
int retval = 0;
if(fileData && fileData->HasChild("levels")){
for(JSONValue* val : fileData->Child("levels")->AsArray()){
++retval;
levelNames.push_back(val->Child("name")->AsString());
levelList.push_back(val);
planetDataList.push_back(fileData->Child("Planets"));
}
}
delete fileData;
return retval;
}
示例3: addChildFromJSON
void addChildFromJSON(
JSONValue* jv,
UIComponent* curParent,
bool isFloating = false
) {
int i;
int j;
int curIcon = 0;
JSONValue* curTempl = NULL;
if (
jv->HasChild("template")
) {
if (
jvTemplates->HasChild(jv->Child("template")->string_value)
) {
curTempl = jvTemplates->Child(jv->Child("template")->string_value);
}
else {
cout << "invalid template \n";// << jv->Child("template")->string_value << "\n";
}
}
for (i = 0; i < E_GST_LENGTH; i++) {
guiStringValues[i] = "";
}
for (i = 0; i < E_GFT_LENGTH; i++) {
guiFloatValues[i] = 0.0f;
}
guiFloatValues[E_GFT_HASBACKGROUND] = 1.0;
guiFloatValues[E_GFT_SINGLELINE] = 1.0;
guiStringValues[E_GST_SS] = "defaultSS";
for (j = 0; j < 2; j++) {
if (curTempl != NULL) {
for (i = 0; i < E_GST_LENGTH; i++) {
if (
curTempl->HasChild(guiStringTypes[i])
) {
guiStringValues[i] = curTempl->Child(guiStringTypes[i])->string_value;
}
}
for (i = 0; i < E_GFT_LENGTH; i++) {
if (
curTempl->HasChild(guiFloatTypes[i])
) {
guiFloatValues[i] = curTempl->Child(guiFloatTypes[i])->number_value;
}
}
}
curTempl = jv;
}
guiFloatValues[E_GFT_LAYER] = max(guiFloatValues[E_GFT_LAYER],(float)(curParent->layer));
UIComponent* newParent = curParent->addChild(
curParent->nodeId,
nodeCount,
guiStringValues,
guiFloatValues,
isFloating,
jv
);
nodeCount++;
int numChildren = 0;
int numFloatingChildren = 0;
int numDataChildren = 0;
int numFilters = 0;
JSONValue* jvChildren = NULL;
JSONValue* jvFloatingChildren = NULL;
JSONValue* jvChildTemplate = NULL;
JSONValue* jvFilter = NULL;
JSONValue* curFilter = NULL;
JSONValue* jvData = NULL;
JSONValue* jvDataRoot = NULL;
JSONValue* curData = NULL;
if (jv->HasChild("children")) {
jvChildren = jv->Child("children");
numChildren = jvChildren->CountChildren();
}
for (i = 0; i < numChildren; i++) {
addChildFromJSON(jvChildren->Child(i),newParent, false);
}
if (jv->HasChild("floatingChildren")) {
jvFloatingChildren = jv->Child("floatingChildren");
//.........这里部分代码省略.........