本文整理汇总了C++中TileSet::SetTileCollidable方法的典型用法代码示例。如果您正苦于以下问题:C++ TileSet::SetTileCollidable方法的具体用法?C++ TileSet::SetTileCollidable怎么用?C++ TileSet::SetTileCollidable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TileSet
的用法示例。
在下文中一共展示了TileSet::SetTileCollidable方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ImportTileMap
//.........这里部分代码省略.........
else if(m_map->GetNumTileLayers() < 3)
{
gd::LogMessage(_("There are less than 3 tiles layers. Upper layer(s) will be empty."));
}
for(std::size_t i = 0; i < std::min(3, m_map->GetNumTileLayers()); i++)
{
const Tmx::TileLayer *layer = m_map->GetTileLayer(i);
for(std::size_t x = 0; x < tileMap.GetColumnsCount(); x++)
{
for(std::size_t y = 0; y < tileMap.GetRowsCount(); y++)
{
//Only tiles provided by the first tileset are imported (and also tests for empty tiles)
if(m_map->FindTilesetIndex(layer->GetTileGid(x, y)) == 0)
{
tileMap.SetTile(i, x, y, layer->GetTileId(x, y));
}
}
}
}
gd::LogStatus(_("Tilemap content importation completed."));
}
//Import the hitboxes
if(importHitboxes)
{
const Tmx::Tileset *importedTileset = m_map->GetTileset(0);
//Set all tiles not collidable in the tileset
tileSet.ResetHitboxes();
for(std::size_t i = 0; i < tileSet.GetTilesCount(); i++)
tileSet.SetTileCollidable(i, false);
if(!importTileSetConf && !importTileSetImage)
CheckTilesCount(tileSet);
bool hasMoreThanOneObjectPerTile = false;
bool hasNotPolygoneObject = false;
bool hasNotConvexPolygon = false;
for(auto it = importedTileset->GetTiles().cbegin();
it != importedTileset->GetTiles().cend();
++it)
{
const Tmx::Tile *importedTile = *it;
if(importedTile->GetId() < tileSet.GetTilesCount()) //Check if the tileset has enough tiles to receive the imported hitboxes
{
if(importedTile->HasObjects())
{
//Set the tile collidable and gets its hitbox
tileSet.SetTileCollidable(importedTile->GetId(), true);
TileHitbox &tileHitbox = tileSet.GetTileHitboxRef(importedTile->GetId());
//Warn the user if more than one hitbox per tile is found
if(importedTile->GetNumObjects() > 1)
hasMoreThanOneObjectPerTile = true;
const Tmx::Object *importedObj = importedTile->GetObject(0);
if(!importedObj->GetPolyline() && !importedObj->GetEllipse())
{
Polygon2d polygonHitbox;
if(!importedObj->GetPolygon())
{