当前位置: 首页>>代码示例>>C++>>正文


C++ JSONValue::CountChildren方法代码示例

本文整理汇总了C++中JSONValue::CountChildren方法的典型用法代码示例。如果您正苦于以下问题:C++ JSONValue::CountChildren方法的具体用法?C++ JSONValue::CountChildren怎么用?C++ JSONValue::CountChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JSONValue的用法示例。


在下文中一共展示了JSONValue::CountChildren方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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());
}
开发者ID:dedmons,项目名称:416-Game-Framework,代码行数:47,代码来源:manager.cpp

示例2: 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");
//.........这里部分代码省略.........
开发者ID:BrendanBuono,项目名称:voxelquestiso,代码行数:101,代码来源:f00330_gamegui.hpp


注:本文中的JSONValue::CountChildren方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。