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


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

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


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

示例1: LoadMap

	void Map::LoadMap()
	{
		pugi::xml_document xmlDoc;
		pugi::xml_parse_result xmlParseResult = xmlDoc.load_file(al_path_cstr(mapPath_,'/'));
		//should check xmlParseResult
		pugi::xml_node xmlMap = xmlDoc.child("map");
		width_ = xmlMap.attribute("width").as_int();
		height_ = xmlMap.attribute("height").as_int();
		playerplaced_ = xmlMap.attribute("playerplaced").as_bool();
		playerStartY_ = xmlMap.attribute("playery").as_int();
		playerStartX_ = xmlMap.attribute("playerx").as_int();
		//Start first node
		//Will probably make a node iterator later if the map has many objects in it
		pugi::xml_node xmlTileSet = xmlMap.child("tilevector");
		int i = 0;
		int j = 0;
		tiles_.resize(0);
		tiles_.clear();
		//is this the best way to clean those objects?
		tiles_.resize(width_);
		for(i = 0; i < tiles_.size(); i++)
		{
			tiles_[i].resize(height_);
		}
		i = 0;
		for (pugi::xml_node_iterator xmlCurrentTile = xmlTileSet.children().begin(); xmlCurrentTile != xmlTileSet.children().end(); xmlCurrentTile++)
		{
			Tile* currentTile = &tiles_[i][j];
			for(pugi::xml_attribute_iterator xmlTileAttribute = xmlCurrentTile->attributes_begin(); xmlTileAttribute != xmlCurrentTile->attributes_end(); xmlTileAttribute++)
			{
				auto currentTileAttributeName = xmlTileAttribute->name();
				if(strcmp(currentTileAttributeName,"tiletype") == 0)
				{
					currentTile->SetTileType(EnumDLL::TILETYPE(xmlTileAttribute->as_int()));
				}
				else if(strcmp(currentTileAttributeName,"x") == 0)
				{
					currentTile->SetCurrentPositionX(xmlTileAttribute->as_double());
				}
				else if(strcmp(currentTileAttributeName,"y") == 0)
				{
					currentTile->SetCurrentPositionY(xmlTileAttribute->as_double());
				}
				else if(strcmp(currentTileAttributeName,"clickable") == 0)
				{
					currentTile->SetClickable(xmlTileAttribute->as_bool());
				}
				else if(strcmp(currentTileAttributeName,"color_a") == 0)
				{
					currentTile->SetColorA(xmlTileAttribute->as_float());
				}
				else if(strcmp(currentTileAttributeName,"color_b") == 0)
				{
					currentTile->SetColorB(xmlTileAttribute->as_float());
				}
				else if(strcmp(currentTileAttributeName,"color_g") == 0)
				{
					currentTile->SetColorG(xmlTileAttribute->as_float());
				}
				else if(strcmp(currentTileAttributeName,"color_r") == 0)
				{
					currentTile->SetColorR(xmlTileAttribute->as_float());
				}
				else if(strcmp(currentTileAttributeName,"height") == 0)
				{
					currentTile->SetHeight(xmlTileAttribute->as_double());
				}
				else if(strcmp(currentTileAttributeName,"width") == 0)
				{
					currentTile->SetWidth(xmlTileAttribute->as_double());
				}
				else if(strcmp(currentTileAttributeName,"movespeed") == 0)
				{
					currentTile->SetMoveSpeed(xmlTileAttribute->as_double());
				}
			}


			//go through the tiles actual nodes for images
			for (pugi::xml_node_iterator xmlCurrentTileNode = xmlCurrentTile->children().begin(); xmlCurrentTileNode != xmlCurrentTile->children().end(); xmlCurrentTileNode++)
			{
				auto currentTileNodeName = xmlCurrentTileNode->name();
				//if no img property it will skip from settings its property
				if(strcmp(currentTileNodeName,"image") == 0)
				{
					auto imgId = xmlCurrentTileNode->attribute("id").as_int();
					for(int k = 0; k < imageLoader_->GetImageSetDictionary().size(); k++)
					{
						if(imageLoader_->GetImageSetDictionary()[k]->GetImageSetId() == EnumDLL::IMAGESETS::TILEIMAGESET)
						{
							for(int j = 0; j < imageLoader_->GetImageSetDictionary()[k]->GetImageDictionary().size(); j++)
							{
								if(imageLoader_->GetImageSetDictionary()[k]->GetImageDictionary()[j]->GetId() == imgId)
								{
									currentTile->SetObjectImageColor(imageLoader_->GetImageSetDictionary()[k]->GetImageDictionary()[j]);
								}
							}
						}
					}
				}
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


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