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


C++ Tile::GetId方法代码示例

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


在下文中一共展示了Tile::GetId方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Parse

    void Tileset::Parse(const tinyxml2::XMLNode *tilesetNode) 
    {
        const tinyxml2::XMLElement *tilesetElem = tilesetNode->ToElement();

        // Read all the attributes into local variables.
        first_gid = tilesetElem->IntAttribute("firstgid");
        tile_width = tilesetElem->IntAttribute("tilewidth");
        tile_height = tilesetElem->IntAttribute("tileheight");
        margin = tilesetElem->IntAttribute("margin");
        spacing = tilesetElem->IntAttribute("spacing");

        name = tilesetElem->Attribute("name");

        // Parse the image.
        const tinyxml2::XMLNode *imageNode = tilesetNode->FirstChildElement("image");
        
        if (imageNode) 
        {
            image = new Image();
            image->Parse(imageNode);
        }

        // Populate the tile list
        int tileCount = (image->GetWidth() / tile_width) * (image->GetHeight() / tile_height);

        int tId = tiles.size();
        while (tId < tileCount)
        {
            Tile* tile = new Tile(tId);
            tiles.push_back(tile);
            tId++;
        }


        // Iterate through all of the tile elements and parse each.
        const tinyxml2::XMLNode *tileNode = tilesetNode->FirstChildElement("tile");
        while (tileNode)
        {
            // Parse it to get the tile id.
            Tile tile;
            tile.Parse(tileNode);

            // Using the ID in the temporary tile get the real tile and parse for real.
            tiles[tile.GetId()]->Parse(tileNode);

            //tileNode = tilesetNode->IterateChildren("tile", tileNode); FIXME MAYBE
            tileNode = tileNode->NextSiblingElement("tile");
        }

        
        // Parse the properties if any.
        const tinyxml2::XMLNode *propertiesNode = tilesetNode->FirstChildElement("properties");
        
        if (propertiesNode) 
        {
            properties.Parse(propertiesNode);
        }
    }
开发者ID:TapkaiNKooH,项目名称:Purity2D,代码行数:58,代码来源:TmxTileset.cpp

示例2: PrefillDataFromCache

  /**
   * (Partially) prefill the given tiles with data already cached with data of the given types.
   *
   * Currently prefill is done by looking for the parent tile in the cache
   * and copying data that intersects the bounding box of the given tile.
   */
  void DataTileCache::PrefillDataFromCache(Tile& tile,
                                            const TypeInfoSet& nodeTypes,
                                            const TypeInfoSet& wayTypes,
                                            const TypeInfoSet& areaTypes,
                                            const TypeInfoSet& optimizedWayTypes,
                                            const TypeInfoSet& optimizedAreaTypes)
  {
    if (tile.GetId().GetLevel()>0) {
      TileId parentTileId=tile.GetId().GetParent();
      TileRef parentTile=GetCachedTile(parentTileId);

      GeoBox boundingBox=tile.GetBoundingBox();

      if (parentTile) {
        ResolveNodesFromParent(tile,*parentTile,boundingBox,nodeTypes);
        ResolveOptimizedWaysFromParent(tile,*parentTile,boundingBox,optimizedWayTypes,wayTypes);
        ResolveWaysFromParent(tile,*parentTile,boundingBox,wayTypes);
        ResolveOptimizedAreasFromParent(tile,*parentTile,boundingBox,optimizedAreaTypes,areaTypes);
        ResolveAreasFromParent(tile,*parentTile,boundingBox,areaTypes);

        return;
      }
    }

    /*
    Magnification zoomedInMagnification;

    zoomedInMagnification.SetLevel(tile.GetId().GetLevel()+1);

    TileId childIds[4]={TileId(zoomedInMagnification,tile.GetId().GetX()*2,tile.GetId().GetY()*2),
                        TileId(zoomedInMagnification,tile.GetId().GetX()*2+1,tile.GetId().GetY()*2),
                        TileId(zoomedInMagnification,tile.GetId().GetX()*2,tile.GetId().GetY()*2+1),
                        TileId(zoomedInMagnification,tile.GetId().GetX()*2+1,tile.GetId().GetY()*2+1)};

    TileRef childTiles[4];

    for (size_t i=0; i<4; i++) {
      childTiles[i]=GetCachedTile(childIds[i]);
    }

    if (childTiles[0] && childTiles[1] && childTiles[2] && childTiles[3]) {
      std::cout << "Prefilling from children..." << std::endl;
    }*/
  }
开发者ID:Framstag,项目名称:libosmscout,代码行数:50,代码来源:DataTileCache.cpp

示例3: Parse

	void Tileset::Parse(const TiXmlNode *tilesetNode) 
	{
		const TiXmlElement *tilesetElem = tilesetNode->ToElement();

		// Read all the attributes into local variables.
		tilesetElem->Attribute("firstgid", &first_gid);
		tilesetElem->Attribute("tilewidth", &tile_width);
		tilesetElem->Attribute("tileheight", &tile_height);
		tilesetElem->Attribute("margin", &margin);
		tilesetElem->Attribute("spacing", &spacing);

		name = tilesetElem->Attribute("name");

		// IGNACIO CEA
		// Parser the offset
		const TiXmlNode *offsetNode = tilesetNode->FirstChild("tileoffset");

		if (offsetNode)
		{
			const TiXmlElement *offsetElement = offsetNode->ToElement();
			offsetElement->Attribute("x", &x_offset);
			offsetElement->Attribute("y", &y_offset);
		}
		// IGNACIO CEA

		// Parse the image.
		const TiXmlNode *imageNode = tilesetNode->FirstChild("image");
		
		if (imageNode) 
		{
			image = new Image();
			image->Parse(imageNode);
		}

        // Populate the tile list
        int tileCount = (image->GetWidth() / tile_width) * (image->GetHeight() / tile_height);

        int tId = tiles.size();
        while (tId < tileCount)
        {
            Tile* tile = new Tile(tId);
            tiles.push_back(tile);
            tId++;
        }


        // Iterate through all of the tile elements and parse each.
        const TiXmlNode *tileNode = tilesetNode->FirstChild("tile");
        while (tileNode)
		{
            // Parse it to get the tile id.
            Tile tile;
            tile.Parse(tileNode);

            // Using the ID in the temporary tile get the real tile and parse for real.
            tiles[tile.GetId()]->Parse(tileNode);

            tileNode = tilesetNode->IterateChildren("tile", tileNode);
		}

		
		// Parse the properties if any.
		const TiXmlNode *propertiesNode = tilesetNode->FirstChild("properties");
		
		if (propertiesNode) 
		{
			properties.Parse(propertiesNode);
		}
	}
开发者ID:Commnets,项目名称:QGAMES,代码行数:69,代码来源:TmxTileset.cpp

示例4: Parse

    void Tileset::Parse(const tinyxml2::XMLNode *tilesetNode, const std::string& file_path)
    {
        const tinyxml2::XMLElement *tilesetElem = tilesetNode->ToElement();

        // Read all the attributes into local variables.

        // The firstgid and source attribute are kept in the TMX map,
        // since they are map specific.
        first_gid = tilesetElem->IntAttribute("firstgid");

        // If the <tileset> node contains a 'source' tag,
        // the tileset config should be loaded from an external
        // TSX (Tile Set XML) file. That file has the same structure
        // as the <tileset> element in the TMX map.
        const char* source_name = tilesetElem->Attribute("source");

        tinyxml2::XMLDocument tileset_doc;
        if ( source_name )
        {
            std::string fileName = file_path + source_name;
            tileset_doc.LoadFile( fileName.c_str() );

            if ( tileset_doc.ErrorID() != 0)
            {
                fprintf(stderr, "failed to load tileset file '%s'\n", fileName.c_str());
                return;
            }

            // Update node and element references to the new node
            tilesetNode = tileset_doc.FirstChildElement("tileset");
            tilesetElem = tilesetNode->ToElement();
        }

        tile_width = tilesetElem->IntAttribute("tilewidth");
        tile_height = tilesetElem->IntAttribute("tileheight");
        margin = tilesetElem->IntAttribute("margin");
        spacing = tilesetElem->IntAttribute("spacing");

        name = tilesetElem->Attribute("name");

        // Parse the tile offset, if it exists.
        const tinyxml2::XMLNode *tileOffsetNode = tilesetNode->FirstChildElement("tileoffset");
        
        if (tileOffsetNode) 
        {
            tileOffset = new TileOffset();
            tileOffset->Parse(tileOffsetNode);
        }

        // Parse the terrain types if any.
        const tinyxml2::XMLNode *terrainTypesNode = tilesetNode->FirstChildElement("terraintypes");
        
        if (terrainTypesNode) 
        {
            TerrainArray terrainArray;
            terrainArray.Parse(&terrainTypes, terrainTypesNode);
        }

        // Parse the image.
        const tinyxml2::XMLNode *imageNode = tilesetNode->FirstChildElement("image");
        
        if (imageNode) 
        {
            image = new Image();
            image->Parse(imageNode);
        }

        // Populate the tile list
        int tileCount = (image->GetWidth() / tile_width) * (image->GetHeight() / tile_height);

        int tId = tiles.size();
        while (tId < tileCount)
        {
            Tile* tile = new Tile(tId);
            tiles.push_back(tile);
            tId++;
        }


        // Iterate through all of the tile elements and parse each.
        const tinyxml2::XMLNode *tileNode = tilesetNode->FirstChildElement("tile");
        while (tileNode)
        {
            // Parse it to get the tile id.
            Tile tile;
            tile.Parse(tileNode);

            // Using the ID in the temporary tile get the real tile and parse for real.
            tiles[tile.GetId()]->Parse(tileNode);

            //tileNode = tilesetNode->IterateChildren("tile", tileNode); FIXME MAYBE
            tileNode = tileNode->NextSiblingElement("tile");
        }

        
        // Parse the properties if any.
        const tinyxml2::XMLNode *propertiesNode = tilesetNode->FirstChildElement("properties");
        
        if (propertiesNode) 
        {
//.........这里部分代码省略.........
开发者ID:aquafox,项目名称:debuggame,代码行数:101,代码来源:TmxTileset.cpp


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