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


C++ MapObject::CreateDebugShape方法代码示例

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


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

示例1: if


//.........这里部分代码省略.........
						resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(point));
					}

					resultObject.m_shapeType = MapObject::Ellipse;
				}
				else if (object->GetGid()) {
					sf::Color color = sf::Color(255u, 255u, 255u, 255u);

					sf::Vertex v0, v1, v2, v3;

					unsigned int gid = object->GetGid() - 1;
					Map::TileInfo tileInfo = resultMap->m_tileInfo[gid];

					v0.texCoords = tileInfo.coords[0] + sf::Vector2f(0.5f, 0.5f);
					v1.texCoords = tileInfo.coords[1] + sf::Vector2f(-0.5f, 0.5f);
					v2.texCoords = tileInfo.coords[2] + sf::Vector2f(-0.5f, -0.5f);
					v3.texCoords = tileInfo.coords[3] + sf::Vector2f(0.5f, -0.5f);

					v0.position = sf::Vector2f();
					v1.position = sf::Vector2f(size.x, 0.0f);
					v2.position = sf::Vector2f(size.x, size.y);
					v3.position = sf::Vector2f(0.0f, size.y);

					resultObject.m_position += sf::Vector2f((tileWidth - size.x) / 2, (tileHeight - size.y)) - resultMap->IsoToOrtho(tileWidth / 2.0f, 0.0f) - offset;
					sf::Vector2f position = resultObject.m_position;

					v0.position += position;
					v1.position += position;
					v2.position += position;
					v3.position += position;

					v0.color = color;
					v1.color = color;
					v2.color = color;
					v3.color = color;

					size_t id = tileInfo.tilesetID;
					if (objectLayer.m_layerSets.find(id) == objectLayer.m_layerSets.end())
					{
						objectLayer.m_layerSets.insert(std::make_pair(id,
							std::make_shared<LayerSet>(*resultMap->m_tilesetTextures[id],
								sf::Vector2u(map->GetWidth(), map->GetHeight()),
								sf::Vector2u(tileWidth, tileHeight))));
					}

					const int x = static_cast<int>(object->GetX() / tileWidth);
					const int y = static_cast<int>(object->GetY() / tileHeight);
					objectLayer.m_layerSets[id]->AddTile(v0, v1, v2, v3, x, y, tileInfo.animated, gid);

					resultObject.m_polypoints.push_back((sf::Vector2f(0.0f, size.y / 2.0f)));
					resultObject.m_polypoints.push_back((sf::Vector2f(size.x / 2.0f, 0.0f)));
					resultObject.m_polypoints.push_back((sf::Vector2f(size.x, size.y / 2.0f)));
					resultObject.m_polypoints.push_back((sf::Vector2f(size.x / 2.0f, size.y)));

					resultObject.m_shapeType = MapObject::Tile;
				}
				else {
					resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(sf::Vector2f()));
					resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(sf::Vector2f(size.x, 0.0f)));
					resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(sf::Vector2f(size.x, size.y)));
					resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(sf::Vector2f(0.0f, size.y)));

					resultObject.m_shapeType = MapObject::Rectangle;
				}
			}
			else if (object->GetPolygon()) {
				const Tmx::Polygon* polygon = object->GetPolygon();

				for (int k = 0; k < polygon->GetNumPoints(); k++)
				{
					const Tmx::Point &point = polygon->GetPoint(k);

					resultObject.m_polypoints.push_back(resultMap->IsoToOrtho(static_cast<float>(point.x), static_cast<float>(point.y)));
				}

				resultObject.m_shapeType = MapObject::Polygon;
			}
			else if (object->GetPolyline()) {
				//TODO: load polyline

				resultObject.m_shapeType = MapObject::Polyline;
			}

			resultObject.m_name = object->GetName();
			resultObject.m_type = object->GetType();
			resultObject.m_visible = object->IsVisible();
			resultObject.CreateDebugShape(sf::Color::Red);
			resultObject.m_tileRatio = tileRatio;

			resultObject.m_properties = object->GetProperties().GetList();

			objectLayer.m_objects.push_back(std::make_shared<MapObject>(resultObject));
		}

		resultMap->m_layers.push_back(objectLayer);
	}

	delete map;
	return resultMap;
}
开发者ID:Rexagon,项目名称:licesium,代码行数:101,代码来源:MapLoader.cpp


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